假设我有'伙伴'这个词
第一个数组用音节打破了这个词,例如。 ['bud','dy']
第二个数组是通过他们的录音分手例如。 ['b','u','dd',y']
现在我的问题是表情符号'dd'应该是'd','d'因为那里有一个音节中断但是我想不出一个有效的方法来解析两个数组并打破表情符号以便它是['b','u','d','d',y']
这里有一些其他的例子
字:车道
音节:['drive','way']
录音制品:['d','r','i','ew','ay']
应该是:['d','r','i','v','e','w','ay']
字词:获取
音节:['get','ting']
录音制品:['g','e','tt','i','ng']
应该是:['g','e','t','t','i','ng']
任何人都知道我可以做到这一点吗?
答案 0 :(得分:0)
我会尝试这个[伪代码]
given i = 0, word = ""
for phono in phonograms //loop over all phonograms
word += phonograms[phono] //and try to assemble the current syllable
if word === syllable[i] //we may have found a sullable
i++
word = ""
continue
if not the syllable[i] starts with word //if not syllable starts with word,
//then we have a phono that
//breaks our rules
phonos = phonograms[phono].split("") //so let's split that into characters
for j in phonos
phonograms.splice(phono++, 0, phonos[j]) //and insert to
//the list of phonograms
i++