10. def stem_word(word):
!
"""Takes a single word input and returns the stem."""
!
stemmer = PorterStemmer()
stem = stemmer.stem
stemmed_word = stem(word)
return stemmed_word
15. def calc_bigrams(text, min_freq=100):
!
"""Returns frequency of bigrams from a text input."""
!
words = [w.lower() for w in text]
bcf = BigramCollocationFinder.from_words(words)
bcf.apply_freq_filter(min_freq)
bigrams = bcf.ngram_fd.items()
bigram_list.append(bigrams)
return bigram_list
16. def calc_trigrams(text, min_freq=50):
!
"""Returns frequency of trigrams from a text input."""
!
words = [w.lower() for w in text]
tcf = TrigramCollocationFinder.from_words(words)
tcf.apply_freq_filter(min_freq)
trigrams = tcf.ngram_fd.items()
trigram_list.append(trigrams)
return trigram_list