Page 1 of 1
Random dictionary word for given letter
Posted: Mon Mar 15, 2010 11:46 pm
by sathishkumar
hi everybody
Is there any possible code for getting output in php(all possible word from word dictionary)
for example....for word "werflo"
flower
fowler
reflow
wolfer
Re: Random dictionary word for given letter
Posted: Mon Mar 15, 2010 11:49 pm
by John Cartwright
I think your best bet would be to mutate your string into every possible combination, then perform a look up in a dictionary database to determine which words exist in the given language.
pspell_check() may also be of interest to determining whether the spelling is correct or invalid (assuming you have the pspell extension).
Re: Random dictionary word for given letter
Posted: Mon Mar 15, 2010 11:53 pm
by sathishkumar
Hi john,
Thanks your quick can you guide me with piece of code for this if possible. because i tired but many in vains.
Regards,
sathish
Re: Random dictionary word for given letter
Posted: Mon Mar 15, 2010 11:55 pm
by John Cartwright
What have you tried? ..and what specifically are you having trouble with? I generally won't write anything beyond simple code for anyone without them demonstrating a little effort first.
Re: Random dictionary word for given letter
Posted: Tue Mar 16, 2010 12:00 am
by sathishkumar
I tried to get different combination of letter with looping. and i compared it with word dictionary but it takes much time to processing.
i want extact like unscramble in
http://www.unscramble.net.
Regards,
sathish
Re: Random dictionary word for given letter
Posted: Tue Mar 16, 2010 12:01 am
by John Cartwright
Re: Random dictionary word for given letter
Posted: Tue Mar 16, 2010 12:03 am
by John Cartwright
sathishkumar wrote:I tried to get different combination of letter with looping. and i compared it with word dictionary but it takes much time to processing.
i want extact like unscramble in
http://www.unscramble.net.
Regards,
sathish
Again.. I'm not here to write code for you. I'm here to help you learn..
Post what you have tried, and we can move forward from there.
Re: Random dictionary word for given letter
Posted: Tue Mar 16, 2010 12:10 am
by sathishkumar
John I found word permutation there is no problem in it. but when compare it with word dictionary inside my database. it takes much time john(looping to compare 4 lakh words). is there any binary search for this?
Regards,
sathish
Re: Random dictionary word for given letter
Posted: Tue Mar 16, 2010 1:02 am
by John Cartwright
Performing a query against all permutations should not take long at all assuming you have a properly indexed your table.
Code: Select all
$permutations = your_permutation_function('foobar'); //array of permutations
$sql = "
SELECT *
FROM dictionary
WHERE word IN ('". implode("','", $permutations) ."')
";
I have asked you twice already to post what you have tried so far. This is the last time I will post here until you can provide the code you have done. I am simply grasping at straws otherwise...
It would also be helpful to see your table structure.