I have create a dataset as follows using bigrams index product_action ('customer', 'called') action ('customer', 'service') action ('blue', 'dress') product ('the', 'service') product ('to', 'complain') action ('complain', 'about') action ('service', 'received') action ('the', 'dress') product I want to know if in each sentence how many times the combination has occured for the entire dataset I have tried to use a count on the bigram def get_bigrams(text): tokens = nltk.word_tokenize(text.lower()) return list(ngrams(tokens, 2)) def count_bigrams(text, bigram): bigrams = get_bigrams(text) return bigrams.count(bigram) The dataset I have in mind is as follows: product action count ('blue', 'dress') ('customer', 'called') 10 Continue reading...