【发布时间】:2014-04-22 21:19:57
【问题描述】:
我的目标是根据一组规则为任何单词生成音标。
首先,我想将单词分成音节。例如,我想要一个算法在一个单词中找到“ch”,然后将其分开,如下所示:
Input: 'aachbutcher'
Output: 'a' 'a' 'ch' 'b' 'u' 't' 'ch' 'e' 'r'
我已经来了这么远:
check=regexp('aachbutcher','ch');
if (isempty(check{1,1})==0) % Returns 0, when 'ch' was found.
[match split startIndex endIndex] = regexp('aachbutcher','ch','match','split')
%Now I split the 'aa', 'but' and 'er' into single characters:
for i = 1:length(split)
SingleLetters{i} = regexp(split{1,i},'.','match');
end
end
我的问题是:如何将单元格放在一起,以使它们的格式与所需的输出一样?我只有匹配部分('ch')的起始索引,但没有拆分部分('aa'、'but'、'er')的起始索引。
有什么想法吗?
【问题讨论】:
-
取
startIndex的 diff 得到长度?
标签: regex string matlab split phonetics