How to match words that rhyme?

Hello hello!

How do I match words that rhyme, like end rhymes, last syllable
rhymes, double rhymes, beginning rhymes and first syllable rhymes?

Like rhymer.com. I’m looking to improve my freestyle skills :slight_smile:

Much obliged, and thanks!

On Sat, Aug 30, 2008 at 1:33 PM, Redd V. [email protected]
wrote:

These links may be of some use (nothing Ruby specific though):
http://www.bradleybuda.com/rhymes/
http://www.algorithm.co.il/blogs/index.php/programming/python/rhyme-and-reason-with-python/

HTH,
Michael G.

-------- Original-Nachricht --------

Datum: Sun, 31 Aug 2008 02:33:34 +0900
Von: “Redd V.” [email protected]
An: [email protected], [email protected]
Betreff: How to match words that rhyme?


http://www.home.no/reddvinylene

Dear Redd,

assuming that you are talking about written text, you might modify the
diff/lcs algorithm

http://raa.ruby-lang.org/project/diff-lcs/

assigning weights to the changes to sort out those pairs of words which
have long substrings at the beginning or at the end in common.

If you want to search for English rhymes, a problem might be that
English spelling is not
very phonetic in many cases.
For this, there’s the soundex algorithm (you’ll find several Ruby
implementations on the web).

Best regards,

Axel

Redd V. wrote:

Hello hello!

How do I match words that rhyme, like end rhymes, last syllable
rhymes, double rhymes, beginning rhymes and first syllable rhymes?

Like rhymer.com. I’m looking to improve my freestyle skills :slight_smile:

http://www.youtube.com/watch?v=SmqXKbxDoJ0

Much obliged, and thanks!

English is extremely inconsistent. Good doesn’t rhyme with food which
doesn’t rhyme with flood. You’re going to need something that describes
the phonetics of each word, like an open dictionary. With that, you
should be able to identify which words rhyme.

Rhyme is a subjective term as well. Some words “rhyme” even though they
don’t meet any formal definition of “rhyme,” they just sound right
together. But this is a lesser concern.

-------- Original-Nachricht --------

Datum: Sun, 31 Aug 2008 03:24:05 +0900
If you want to search for English rhymes, a problem might be that English
spelling is not
very phonetic in many cases.
For this, there’s the soundex algorithm (you’ll find several Ruby
implementations on the web).

or even metaphone (http://raa.ruby-lang.org/project/metaphone/)

look also here : http://www.codeproject.com/KB/string/dmetaphone6.aspx

Best regards,

Axel

Michael M. wrote:

English is extremely inconsistent. Good doesn’t rhyme with food which
doesn’t rhyme with flood. You’re going to need something that describes
the phonetics of each word, like an open dictionary. With that, you
should be able to identify which words rhyme.

Rhyme is a subjective term as well. Some words “rhyme” even though they
don’t meet any formal definition of “rhyme,” they just sound right
together. But this is a lesser concern.

Maybe I’m missing something subtle, but isn’t this what soundex is for?

http://en.wikipedia.org/wiki/Soundex

It’s definitely not perfect; my experience has been it generally works
better to catch misspellings in proper nouns than anything else, but it
could be potentially useful in the first part of a multi-step filtering
process.

At the worst, soundex is found damn near everywhere (even in some SQL
Database implementations… I’d be surprised if there wasn’t a ruby one)
and it should be easy to test (and rule out, if necessary) with a
wordlist.

-Erik

Axel E. wrote:

-------- Original-Nachricht --------

Datum: Mon, 1 Sep 2008 12:09:01 +0900
Von: Erik H. [email protected]
An: [email protected]
Betreff: Re: How to match words that rhyme?

Maybe I’m missing something subtle, but isn’t this what soundex is for?
… which is why I had proposed it in a previous post.
But Michael is right with his examples … a great number of
often-occurring
words that are classified as similar won’t sound similar.

Missed that, sorry.

However, soundex would be good (and fast) to greatly reduce a base
wordlist, it may still catch words that don’t sound alike, but the
likelihood of it omitting words that sound alike is so low it’s probably
worth it, and at that point you can apply a more expensive algorithm to
the smaller set.

Of course, I am under the assumption he wants to scan a ton of unrelated
words (say, a whole dictionary) to match against his word.

-Erik

-------- Original-Nachricht --------

Datum: Mon, 1 Sep 2008 12:09:01 +0900
Von: Erik H. [email protected]
An: [email protected]
Betreff: Re: How to match words that rhyme?

Maybe I’m missing something subtle, but isn’t this what soundex is for?
… which is why I had proposed it in a previous post.
But Michael is right with his examples … a great number of
often-occurring
words that are classified as similar won’t sound similar.
So, a good dictionary with phonetic information seems the best idea to
go for,
Maybe Wiktionary ? I also liked the American Heritage Dictionary (but I
think if you
want to use it as often as you’d need to generate a dictionary of
sound-alike words,
you’d have to buy the installed version, and I don’t know if it runs
under anything
else than Windows…)

Best regards,

Axel

On Mon, Sep 1, 2008 at 12:49 PM, Erik H. [email protected]
wrote:

BTW, this would make a great Ruby Q… :slight_smile:

Hehe, I thought so too :slight_smile:

Erik H. wrote:

However, soundex would be good (and fast) to greatly reduce a base
wordlist, it may still catch words that don’t sound alike, but the
likelihood of it omitting words that sound alike is so low it’s probably
worth it, and at that point you can apply a more expensive algorithm to
the smaller set.

BTW, this would make a great Ruby Q… :slight_smile:

-Erik

Here is a crude start based on an old version I wrote in Pascal. It
should give you a place to start. (Please do not be TOO brutal in
critique. I am new with writing Ruby algorithms. Elegance will come.)

class Soundex
def soundsAlike word1, word2
soundex(word1) == soundex(word2)
end

def soundex w
w.upcase!
temp1 = w[0,1]
1.upto(w.length - 1) { |i|
case w[i, 1]
when ‘B’,‘F’,‘P’,‘V’
temp1 += ‘1’
when ‘C’,‘G’,‘J’,‘K’,‘Q’,‘S’,‘X’,‘Z’
temp1 += ‘2’
when ‘D’,‘T’
temp1 += ‘3’
when ‘L’
temp1 += ‘4’
when ‘M’, ‘N’
temp1 += ‘5’
when ‘R’
temp1 += ‘6’
end
}
i = 1
while i < temp1.length - 1 do
if temp1[i] == temp1[i + 1]
temp1[i] = ‘’
else
i += 1
end
end
temp1
end
end

s = Soundex.new
p s.soundsAlike(‘their’, ‘there’) # returns true

-------- Original-Nachricht --------

Datum: Wed, 3 Sep 2008 23:09:05 +0900
Von: Lloyd L. [email protected]
An: [email protected]
Betreff: Re: How to match words that rhyme?

w.upcase!
    temp1 += '4'
  else

Posted via http://www.ruby-forum.com/.
Another solution, which could help the problem of non-phonetic writing
in English is to use
the external text-to-speech program espeak:

http://espeak.sourceforge.net/

It can produce a kind of phonetic writing for English like so:

[email protected]:~$ espeak -v mb-en1 ‘dough’ > res
[email protected]:~$ cat res
d 65
@U 294 0 103 80 77 100 77
_ 263
_ 1
[email protected]:~$ espeak -v mb-en1 ‘tough’ > res2
[email protected]:~$ cat res2
t 100
V 129 0 103 80 77 100 77
f 142
_ 263
_ 1
[email protected]:~$ espeak -v mb-en1 ‘bow’ > res3
[email protected]:~$ cat res3
b 65
@U 294 0 103 80 77 100 77
_ 263
_ 1

… this works also in other languages for which the correspondence
between pronounciation and
spelling isn’t one-to-one, e.g., French:

[email protected]:~$ espeak -v mb-fr1 ‘eaux’ > res4
[email protected]:~$ cat res4
o 202 0 103 80 77 100 77
_ 263
_ 1
[email protected]:~$ espeak -v mb-fr1 ‘o’ > res5
[email protected]:~$ cat res5
o 202 0 103 80 77 100 77
_ 263
_ 1

espeak has many “voices” for different languages. For the above to work,
you’ll need to choose Mbrola
voices, because the text-to-speech system Mbrola
(http://tcts.fpms.ac.be/synthesis/mbrola.html) needs
this phonetic text as input.

Best regards,

Axel

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs