473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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
Oct 3 '08 #1
5 2180
On 3 Oct, 01:47, BryanA <Bryan.Andr...@gmail.comwrote:
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) ?
Oct 3 '08 #2
Message-ID:
<20**********************************@u65g2000hsc. googlegroups.comfrom
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
Oct 3 '08 #3
On 3 Oct, 01:47, BryanA <Bryan.Andr...@gmail.comwrote:
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.
Oct 3 '08 #4
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
Oct 3 '08 #5
Response to BryanA <Br***********@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.
Oct 9 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Preston Crawford | last post by:
I'm looking to quickly get a photo album online. Very simple, thumbnails, a few pages, maybe a description, but hopefully a small script that's easy to edit and work into my existing site. I know...
3
by: Alan Clark | last post by:
Dear All I need to do something very simple with Javascript and have been looking all over the web for two days for a suitable script. I'm the kind of person who learns by seeing how it's done....
9
by: Pete | last post by:
Does anyone have a simple html vbscript or other type of snippet they can share that appends a record to a access database via ADO or DAO? I would like to allow users that don't have Microsoft...
0
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I...
27
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res =...
3
by: robert | last post by:
I'm looking for a most simple but save opt-in mailing list script in php (linux Apache CGI, but shouldn't matter) best: * all in one single .php file; different functions by input vars /...
7
by: Wladimir Borsov | last post by:
I want to call a perl script myscript.pl in my cgi-bin from a HTML web page. This call should NOT use SSI (because in this case HTTPS://.... protocol is necessary). Furthermore NO button click...
24
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
5
by: Joel | last post by:
In the course of my project, I must include some custom logic and would like to integrate a small script language in my application for that purpose. In C++, I used the LUA script language and I...
2
by: Bhasker V Kode | last post by:
Hi, I just wanted to share with everyone a new project that i'm launching today called the Returnable Project ( http://returnable.org ) Returnable serves as a open-platform architectural guide...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.