我有一些Trie的功能,我想要产生以下输出:
/*Putting a string into an Entry item I created: parses string, removes
syllable stresses and adds a comma in between the word and its
pronunciation*/
The Line is: MARIBELLE,MA RAH B EY L
/*splits the line into a list using ',' as a delimiter*/
The Entry is Saved as: ['MARIBELLE', 'MA RAH B EY L']
/*self.entry[0]*/
The Word is: MARIBELLE
/*self.entry[1].split(" ")*/
Its Pronunciation is: ['MA', 'RAH', 'B', 'EY', 'L']
/*desired output with word from a word list formatted the same way as the
input line (word sy la bles); here I know it should choose: LORABELLE LO
RAH B EY L*/
The Word With Longest Common Rhyming Suffix is: LORABELLE****
然而,我最长的常见后缀函数正在吐出:
The Longest Rhyming Suffix is: LEYBRAHLO
换句话说,它找到了与输入最接近的匹配,但是我没有能够让它吐出我(很差)用语音向后拼写出来的方式。我希望它反过来检查匹配,因为这应该告诉我输入中的哪些词押韵(后缀检查),而且我不太关心如果我可以只是按正确的顺序打印音节让它返回音节发出的原始单词。
为了学术诚信,我不能在这里发布任何重要的代码示例,但我想知道是否有人能让我走上正轨。
tl; dr - 找到一个与我在trie中的输入押韵的单词后,我怎么能让trie的函数返回那个押韵的单词而不是它的发音呢?