How can I Count every word with three or more syllables in each group of sentences, even if the same word appears more than once.
The only way you can do this is by using a database of word-syllable. Here's one way using www.dictionary.com as the database.
FullText = 'This is a really arbitrary sentence.'; %'really' could be pronounced 'ree-uh-lee' (3 syl) TextCell = regexp(FullText, '\w+', 'match'); TextSyl = cellfun(@(x) getSyllable(x), TextCell); TextSyl = 1 1 1 3 4 2 OneSylWord = sum(TextSyl == 1); OneSylWord = 3
Where getSyllable function is:
function Syl = getSyllable(Word) if nargin == 0 Word = input('What word do you want? ', 's'); end if isempty(Word) Syl = 0; return end Word = strrep(Word, ' ', ''); % Use dictionary.com to get the phonetic transcription of a word % Ex: arbitrary % [ahr-bi-trer-ee] % WARNING: will not work for some words if dictionary.com does not have it % listed as the main word. Example, 'awesomeness' returns 2 because %' awesome' is the main word in the site. try SiteTxt = urlread(sprintf('http://www.dictionary.com/browse/%s?s=t', Word)); catch warning('Could not determine syllable for "%s". Returning 0.', Word); Syl = 0; return end CodeSrch1 = '"pron spellpron"[\s\w\d\>]+\[\s*(?[^\]]+)'; InnerCode = regexp(SiteTxt, CodeSrch1, 'tokens'); InnerCode = InnerCode{1}; CodeSrch2 = '>(?[^\<]+)'; Phonetics = regexp(InnerCode, CodeSrch2, 'tokens'); Phonetics = [Phonetics{1}{:}]; if isempty(Phonetics) Syl = 1; else Phonetics = cat(2, Phonetics{:}); MultWord = regexp(Phonetics, ',', 'split'); %Sometimes many ways to say a word - take 1st option Syl = sum(MultWord{1} == '-') + 1; end
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.