So, I have to find rhyming words. Basically I am getting a bunch of words and I need to compare which ones rhyme. So if I am given words like...

friendl|y, luck|y, murk|y, rapidl|y
luc|ky, mur|ky
frien|dly, rapi|dly

They can also rhyme with other words, so a word could appear more then once. I am really stuck at finding an algorithm for this. I orginally reverse all the words, sorted them and reversed them back. While that worked on finding words that rhyme, it does not give me if a word rhymes with other words. Also the output needs to be sorted alphabatecially as well as the length of the rhyming part. so the |y will come first then |ky and |dly

Can anyone help me find an algorithm to sovle this?

Note: the words arent given with the | I need to insert that my self

Edited by johsh.hanks

4 Years
Discussion Span
Last Post by johsh.hanks

Maybe create some kind of Map<String, ArrayList<String>> where the keys are the unique different last part of the words and the values are lists of all the words that end with that last part.
That's a relatively esasy structure to build as you iterate through the sorce data, and at the end each list will contain words that rhyme with each other.


Can you please explain a little bit more. I also need to insert a | on parts that rhyme

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.