Get Top N Frequent Words
Have you seen this question before?
Given an example paragraph string and an integer , write a function
n_frequent_wordsthat returns the top frequent words in the posting and the frequencies for each word.
What’s the function run-time?
posting = """ Herbal sauna uses the healing properties of herbs in combination with distilled water. The water evaporates and distributes the effect of the herbs throughout the room. A visit to the herbal sauna can cause real miracles, especially for colds. """ n = 3
Next question: Search Algorithm Recall
n_frequent_words(posting,N) = [ ('the', 6), ('herbal', 2), ('sauna', 2), ]
Use Shift + Enter to run code