To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Newbies

Newbies Help for those who are just getting started

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-29-2005, 03:54 PM   #1
scorpioy
Senior Member
 
Join Date: May 2004
Location: CA
Posts: 189
php spell check functions

Im trying to implement word correction like google's Did you mean .....
I looked at here here

I tried the code:
Code:
<?php
function spellcheck ( $string ) {
   $words = split(' ',$string);
   $misspelled = $return = array();
   pspell_config_create("en",PSPELL_NORMAL);
   $int = pspell_new('en');
   foreach ($words as $value) {
       $check = preg_split('/[\W]+?/',$value);
       if (($check[1] != '') and (strpos("'",$value) > 0) ) {$check[0] = $value;}
       if (($check[0] + 1 == 1) and (!pspell_check($int, $check[0]) )) {
           $res  .= '<SPAN class="misspelled" style="color:#FF0000; font-weight:bold;">' . $value . ' </SPAN> ';
           $poss = pspell_suggest($int,$value);
           $orig = metaphone($value);
           foreach ($poss as $suggested)
           {
                 $ranked[metaphone($suggested)] = $suggested;
           }
           if ($ranked[$orig] <> '') {$poss[1] = $ranked[$orig];}
          
           $res2  .= '<SPAN style="color:#CC8800; font-weight:bold">' . $poss[1] . ' </SPAN> ';

       } else {
       $res .= $value . ' ';
       $res2 .= $value . ' ';
       }
   }

   $n[1] = $res;
   $n[2] = $res2;
   return $n;
}
?>
But my page displays it does not recognize methods pspell_config_create(), pspell_new() ...

How can I correct it? Did I miss something or do I have to write my own methods for those methods? It would be best if someone can post a correct and complete functions here

Thanks
scorpioy is offline   Reply With Quote
Old 07-29-2005, 04:36 PM   #2
drew010
Senior Member
 
drew010's Avatar
 
Join Date: Apr 2003
Location: Santa Rosa, CA
Posts: 2,835
you mean it says, call to undefined function pspell_new...?

if so, this means you need to install the aspell library files from http://aspell.sourceforge.net and reconfigure php to support the library, for linux you recompile with the switch --with-pspell[=dir] or on windows copy aspell-15.dll to the system32 folder.
drew010 is offline   Reply With Quote
Old 07-29-2005, 05:18 PM   #3
scorpioy
Senior Member
 
Join Date: May 2004
Location: CA
Posts: 189
would this be the place to download library
ftp://ftp.gnu.org/gnu/aspell/

which files should I download? Please give me more detail.

Thank you very much
scorpioy is offline   Reply With Quote
Old 07-29-2005, 05:21 PM   #4
drew010
Senior Member
 
drew010's Avatar
 
Join Date: Apr 2003
Location: Santa Rosa, CA
Posts: 2,835
are you on windows or linux.
drew010 is offline   Reply With Quote
Old 07-29-2005, 05:29 PM   #5
scorpioy
Senior Member
 
Join Date: May 2004
Location: CA
Posts: 189
on linux

thank you
scorpioy is offline   Reply With Quote
Old 07-29-2005, 05:32 PM   #6
drew010
Senior Member
 
drew010's Avatar
 
Join Date: Apr 2003
Location: Santa Rosa, CA
Posts: 2,835
ftp://ftp.gnu.org/gnu/aspell/aspell-0.60.3.tar.gz

install that and recompile php to include the --with-pspell=/path/to/aspell
drew010 is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 12:19 PM.






Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.