How to know what word appears most in a paragraph? (Matlab)
I have a huge paragraph and want to know what word appears most in it. Could anyone please point me in the right direction with this? Any examples and explanations would be helpful. Thanks! X'' Here is a simple solution, should be quite fast. example_paragraph = 'This is an example corpus. Is is a verb?'; words = regexp(example_paragraph, ' ', 'split'); vocabulary = unique(words); n = length(vocabulary); counts = zeros(n, 1); for i=1:n counts(i) = sum(strcmpi(words, vocabulary{i})); end [frequency_of_the_most_frequent_word, idx] = max(counts); most_frequent_word = vocabulary{idx}; You can also