How do I find and display the most frequent word in ALL sentences combined?
2 views (last 30 days)
Show older comments
if I have 5 sentences (s1, s2, s3, s4, s5) and i put them all into one string (s) using:
s=[s1 ' ' s2 ' ' s3 ' ' s4 ' ' s5]
How would I go through all the words in each sentence to ascertain and display the most frequent word in ALL sentences?
0 Comments
Answers (2)
Walter Roberson
on 9 Nov 2013
regexp() with the 'split' option to break the string into words. Then you can unique() the resulting cell array, and examine the third output of unique() to determine how many times each value occurred.
0 Comments
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!