Get Top N Frequent Words
Given an example paragraph string and an integer , write a function
n_frequent_words
that returns the top frequent words in the posting and the frequencies for each word.What’s the function run-time?
Example:
Input:
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
Output:
n_frequent_words(posting,N) = [
('the', 6),
('herbal', 2),
('sauna', 2),
]
Next question: Search Algorithm Recall.....
Loading editor