PDA

View Full Version : Spell Checking


Gamefreak
Mon 13th May '02, 9:16pm
I want to incorporate a spell checker into my site and so I have been looking through my PHP book, and I came across a function in the appendix called pspell_check(). It is used for spell checking, but I am not sure how I would do this. First of all, do you need some special dictionary file to use this? How would I use PHP and/or javascript as sort of an online spell checker (kinda like MS word style)? Thanks for any help!

Conscience
Tue 14th May '02, 2:35am
doing something like what word does would be rather tricky...this is what I do on one of my news scripts.

Firstly, you have to have pspell enabled in your php configs AND have the pspell libraries. [more...] (http://www.php.net/manual/en/ref.pspell.php)


When users submit a post and there is an error (spelling wise), it automatically throws them back into preview post mode. I check the spelling by using pspell_check() (http://www.php.net/manual/en/function.pspell-check.php) and looping though all the words in the post. In the preview they can then hover over words that are marked with red unline (I simply replace "text" with "<font color=red>text</font>" if the spelling is incorrect) and a little hover-box over the mouse appears with suggestions as to the right spelling (done using pspell_suggest() (http://www.php.net/manual/en/function.pspell-suggest.php) and a little java mouse-over script, you can find them everywhere.) Once they are happy that they have corrected their spelling mistakes they can proceed to post.

What my script CANT do is let people click on the suggestion that they think is right and then the script automatically correct it. I don't have the time to stuff around and get this working. IMHO ive done enough to let people know if something is spelt incorrectly, I'm not going to spend hours trying to code stuff to make up for their lazyness as well :)

Gamefreak
Tue 14th May '02, 10:28pm
Thanks for the help! This can really help me. But, at the PHP site, it says you need to compile PHP with the pspell option. Is there a way to enable this without recompiling PHP?!

dabean
Tue 14th May '02, 11:11pm
Originally posted by Gamefreak
Thanks for the help! This can really help me. But, at the PHP site, it says you need to compile PHP with the pspell option. Is there a way to enable this without recompiling PHP?!

Yes and No. Whilst it is technicallly possible to compile pspell as php module on a standalone basis. In reality it is far simpler to recompile php.

Conscience
Wed 15th May '02, 3:22am
yeah, that is what I was refering to in the config thing. and the previous user is right... the easiest way is to recompile php...this usually means a recompile of apache too, depending on your setup :)