Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Sep 15, 2004, 00:12   #1
Brak
SitePoint Addict
 
Brak's Avatar
 
Join Date: Jul 2004
Location: Central Coast, CA
Posts: 365
Rhyming Words

I need an application that will rhyme words... how would be the best way to approach this?

I've thought about it breifly and the best solution I can think of right now is to grab the last three letters and search for them in other words... this seems rediculously not right =/

Any advice?
Brak is offline   Reply With Quote
Old Sep 15, 2004, 02:15   #2
PeterW
SitePoint Evangelist
 
Join Date: Jul 2000
Location: Warwickshire, England
Posts: 590
in php maybe use metaphone() or soundex() on the end of the words?
PeterW is offline   Reply With Quote
Old Sep 15, 2004, 04:15   #3
battye
Simulation Cricketer
 
Join Date: Sep 2004
Location: australia
Posts: 473
So these words will be stored in a database somewhere?
Once you grab the last three letters assign a variable to it ($vari) and run some SQL:

SELECT * FROM tablename WHERE words_column = $vari

hope that helps
battye is offline   Reply With Quote
Old Sep 15, 2004, 04:20   #4
sinapra
SitePoint Addict
 
sinapra's Avatar
 
Join Date: Sep 2004
Location: secunderabad
Posts: 273
could be much closer,
SELECT * FROM tablename WHERE words_column like '%$vari'
sinapra is offline   Reply With Quote
Old Sep 15, 2004, 13:44   #5
Brak
SitePoint Addict
 
Brak's Avatar
 
Join Date: Jul 2004
Location: Central Coast, CA
Posts: 365
Quote:
Originally Posted by PeterW
in php maybe use metaphone() or soundex() on the end of the words?
You rock. So much.

I never knew there was a php function for pronoucing words... amazing.
Brak is offline   Reply With Quote
Old Sep 15, 2004, 21:34   #6
Kevin Yank
SitePoint resident know-it-all
SitePoint Award Recipient
 
Kevin Yank's Avatar
 
Join Date: Apr 2000
Location: Melbourne, Australia
Posts: 2,918
To implement this more rigorously, you'll need a better way to isolate the last syllable of a string/word for comparison with these functions. One way might be to look into implementing Liang's Algorithm in PHP.

Liang's Algorithm is a method for identifying locations in a text document where hyphens could be reasonably inserted. Since hyphens are generally placed between syllables, the same algorithm could work for this problem.

The only description of Liang's Algorithm I could find mentioned online was in the documentation for the TeX page layout software, which can be found online in TeX format. You'll probably want to try to produce a rendered version of the document to read it.

http://sources.redhat.com/ml/xsl-lis.../msg00508.html
Kevin Yank is offline   Reply With Quote
Old Sep 16, 2004, 09:40   #7
VBAjedi
SitePoint Member
 
Join Date: May 2004
Location: Pacific Northwest
Posts: 5
You also might find it helpful to have a look at a rhyming dictionary for songwriters. It would be great if you could just load one of those into your program, but even if you can't, seeing the way it is laid out will give you some insight into the way our ear decides two words "rhyme".
VBAjedi is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 05:29.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved