hyperreality/Poetry-Tools

Improve rhyme function

Opened this issue · 4 comments

At the moment, the rhyme function compares whether the final two syllables from the CMU dictionary are equal. This works for the majority of words, but many cause problems. For instance:

fire -> [[u'F', u'AY1', u'ER0'], [u'F', u'AY1', u'R']]
admire -> [[u'AE0', u'D', u'M', u'AY1', u'R']]
desire -> [[u'D', u'IH0', u'Z', u'AY1', u'ER0']]

Fire matches both admire and desire, but admire doesn't rhyme with desire...

Furthermore, for two syllable words, checking only the last syllable would probably improve things.

I just found a really interesting article that's related. Anything useful here?
http://graphics.wsj.com/hamilton-methodology/

@oscardssmith Thanks, that looks really useful. I'll be thinking about it over the next few days, and also happy to review and merge a patch if you want to try implementing it.

I found that the rhyme function did not work for me until I changed it from level=2 to level=1
def rhymes(word1, word2, level=1):

The rhymes function compares the last x phonemes of the word. So for monosyllabic words, like "show" and "low", it may only report a rhyme if you use level 1. Maybe level 1 is a better default setting to use than level 2, but I think it was too permissive. A system like RhymeBrain which scores rhymes on a scale is probably what we need.