I got this code working but there is a small issue - I'm getting an error with Index exceeds matrix dimensions. This error is coming up when the text file is big. can anybody help me with this please?
Index exceeds matrix dimensions.
Error in getPolySyllWords>getSyllable (line 38)
InnerCode = InnerCode{1};
Error in getPolySyllWords>@(x)getSyllable(x)
Error in getPolySyllWords (line 8)
TextSyl = cellfun(@(x) getSyllable(x), TextCell);
I am getting above error
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, ' ', '');
try
Txt = webread(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
if isempty(InnerCode)
InnerCode = InnerCode{1};
CodeSrch2 = '>(?<Phonetics>[^\<]+)';
Phonetics = regexp(InnerCode, CodeSrch2, 'tokens');
Phonetics = [Phonetics{1}{:}];
else
% handle this case
Syl=1;
return;
end