Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old October 3rd, 2008, 01:55 AM
BryanA
Guest
 
Posts: n/a
Default Simple PHP script?

Here is what I want to do. I want to be able to load a list of
correctly spelled words in and then the script will come up with
misspelled versions of that word and insert it into a mysql db. My
question is, where would I start?

Thanks,
Bryan
  #2  
Old October 3rd, 2008, 10:55 AM
Gremnebulin
Guest
 
Posts: n/a
Default Re: Simple PHP script?

On 3 Oct, 01:47, BryanA <Bryan.Andr...@gmail.comwrote:
Quote:
Here is what I want to do. I want to be able to load a list of
correctly spelled words in and then the script will come up with
misspelled versions of that word and insert it into a mysql db. My
question is, where would I start?
>
Thanks,
Bryan
Are you having problems with the basic loading and saving, or with the
"generating mispelled" bit (which looks vaguely-defined to me) ?
  #3  
Old October 3rd, 2008, 11:35 AM
Geoff Berrow
Guest
 
Posts: n/a
Default Re: Simple PHP script?

Message-ID:
<2051eca3-d689-4bbc-9f63-1128a4ee2d10@u65g2000hsc.googlegroups.comfrom
BryanA contained the following:
Quote:
>Here is what I want to do. I want to be able to load a list of
>correctly spelled words in and then the script will come up with
>misspelled versions of that word and insert it into a mysql db. My
>question is, where would I start?
What for?
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk
  #4  
Old October 3rd, 2008, 01:35 PM
C. (http://symcbean.blogspot.com/)
Guest
 
Posts: n/a
Default Re: Simple PHP script?

On 3 Oct, 01:47, BryanA <Bryan.Andr...@gmail.comwrote:
Quote:
Here is what I want to do. I want to be able to load a list of
correctly spelled words in and then the script will come up with
misspelled versions of that word and insert it into a mysql db. My
question is, where would I start?
>
Thanks,
Bryan
Work out an algorithm, implement the algorithm in PHP then test it.

C.
  #5  
Old October 3rd, 2008, 08:45 PM
Lee Hanken
Guest
 
Posts: n/a
Default Re: Simple PHP script?

BryanA wrote:
Quote:
Here is what I want to do. I want to be able to load a list of
correctly spelled words in and then the script will come up with
misspelled versions of that word and insert it into a mysql db. My
question is, where would I start?
>
Thanks,
Bryan
An algorithm such as the one used in:

http://www.norvig.com/spell-correct.html

can be re-written in php as in the following:

$word = "Spelling";

$word = strtolower($word);

$length = strlen($word);

// deletion
for ($i=0;$i<$length;$i++)
$variants[] = substr($word,0,$i) .
substr($word,$i+1,$length-$i-1);

// transposition
for ($i=0;$i<$length-1;$i++)
$variants[] = substr($word,0,$i) .
substr($word,$i+1,1) .
substr($word,$i,1) .
substr($word,$i+2,$length-$i-2);

// alteration
for ($i=0;$i<$length;$i++)
for ($c=ord('a'); $c <= ord('z'); $c++)
$variants[] = substr($word,0,$i) .
chr($c) .
substr($word,$i+1,$length-$i-1);
// insertion
for ($i=0;$i<$length+1;$i++)
for ($c=ord('a'); $c <= ord('z'); $c++)
$variants[] = substr($word,0,$i) .
chr($c) .
substr($word,$i,$length-$i);
// remove identical variants
foreach ($variants as $n =$variant)
if ($variant == $word)
unset($variants[$n]);

print_r($variants);

-Lee
  #6  
Old October 9th, 2008, 11:25 PM
-Lost
Guest
 
Posts: n/a
Default Re: Simple PHP script?

Response to BryanA <Bryan.Andreas@gmail.com>:
Quote:
Here is what I want to do. I want to be able to load a list of
correctly spelled words in and then the script will come up with
misspelled versions of that word and insert it into a mysql db. My
question is, where would I start?
Unit tests are an ideal place to start. Look for the functionality
you desire.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
 

Bookmarks

Thread Tools

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles