Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Simple PHP script?

 
   Database Help (Home) -> PHP RSS
Next:  What Is Happening  
Author Message
BryanA

External


Since: Oct 02, 2008
Posts: 8



(Msg. 1) Posted: Thu Oct 02, 2008 5:47 pm
Post subject: Simple PHP script?
Archived from groups: comp>lang>php (more info?)

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

 >> Stay informed about: Simple PHP script? 
Back to top
Login to vote
Gremnebulin

External


Since: Nov 26, 2007
Posts: 4



(Msg. 2) Posted: Fri Oct 03, 2008 2:47 am
Post subject: Re: Simple PHP script? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 3 Oct, 01:47, BryanA <Bryan.Andr... DeleteThis @gmail.com> wrote:
> 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) ?

 >> Stay informed about: Simple PHP script? 
Back to top
Login to vote
"C.

External


Since: Dec 30, 2007
Posts: 188



(Msg. 3) Posted: Fri Oct 03, 2008 5:31 am
Post subject: Re: Simple PHP script? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 3 Oct, 01:47, BryanA <Bryan.Andr... RemoveThis @gmail.com> wrote:
> 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.
 >> Stay informed about: Simple PHP script? 
Back to top
Login to vote
Geoff Berrow1

External


Since: Dec 24, 2003
Posts: 359



(Msg. 4) Posted: Fri Oct 03, 2008 8:27 am
Post subject: Re: Simple PHP script? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Message-ID:
<2051eca3-d689-4bbc-9f63-1128a4ee2d10.DeleteThis@u65g2000hsc.googlegroups.com> from
BryanA contained the following:

>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
 >> Stay informed about: Simple PHP script? 
Back to top
Login to vote
Lee Hanken

External


Since: Oct 03, 2008
Posts: 1



(Msg. 5) Posted: Fri Oct 03, 2008 4:25 pm
Post subject: Re: Simple PHP script? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

BryanA wrote:
> 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
 >> Stay informed about: Simple PHP script? 
Back to top
Login to vote
-Lost

External


Since: Sep 30, 2008
Posts: 8



(Msg. 6) Posted: Thu Oct 09, 2008 5:24 pm
Post subject: Re: Simple PHP script? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Response to BryanA <Bryan.Andreas.DeleteThis@gmail.com>:

> 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.
 >> Stay informed about: Simple PHP script? 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> PHP All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]