Solved

Spell Checking in PHP

Posted on 2004-08-16
7
1,328 Views
Last Modified: 2014-12-01
Hi!!
i need a code for spell checking using php, i have not done any thing like this before, i found a lot of information on net,, plus i also found a simple code, that i require,, but now i am having problem running it. i read some where that the pspell can only be used in linux environment. i dont have linux so i uploaded it to the server but still i am getting the error "Fatal error: Call to undefined function: pspell_new() in /home/discrete/public_html/kbase/spell.php".
this is the part of code i am using,,

      $misspelled = array();
      $suggestions = array();
      $original = $text;
      $words = preg_split ("/[\s,.]+/", $text);
      
      $pl = pspell_new ("en");
      
      foreach($words as $key=>$word)
      {
            $checkword = preg_replace("/[^A-z-']/", '', $word);
            if (!pspell_check ($pl, $checkword))
            {
                  $misspelled[$key] = $checkword;
                  $suggestions[$checkword] = pspell_suggest ($pl, $checkword);
            }
      }

can anyone help me,,,
its urgent
regards,,
      
0
Comment
Question by:SadafRasheed
  • 3
  • 2
  • 2
7 Comments
 
LVL 25

Accepted Solution

by:
Marcus Bointon earned 250 total points
ID: 11808026
You probably just need to configure PHP with --with-pspell and recompile it. This is easy on *nix, but difficult on Windows. There are some comments on how to do it here:

http://www.php.net/pspell

I see that on Windows it's mapped to aspell, which I assume is a pspell workalike.
0
 
LVL 4

Author Comment

by:SadafRasheed
ID: 11811077
thanks for the reply,,
i read that document and tried the code provided on te page but i am getting this message
"Warning: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language "en". in C:\Apache2\htdocs\kbase\try.php on line 11"
the code is

<?php
  $str="This is a test for the spell checker function";      
  $ret = spellcheck($str);
  var_dump($ret);

function spellcheck ( $string )
{
   $words = preg_split('/[\W]+?/',$string);
   $misspelled = $return = array();
   
   pspell_config_create("en");
   $int = pspell_new("en");
   
   foreach ($words as $value)
   {
       if (!pspell_check($int, $value))
       {
           $misspelled[] = $value;
       }
   }
   foreach ($misspelled as $value)
   {
       $return[$value] = pspell_suggest($int, $value);
   }
   return $return;
}
?>
i guess the pspell extension is working because i am not getting any undefined function errors
so, now what :$
what am i doing wrong and what should i do to rectify this,,,
waiting for reply,,,
regards,,
0
 
LVL 25

Expert Comment

by:Marcus Bointon
ID: 11811203
It just sounds like you have not installed the dictionaries where it expects to find them. The user notes have a comment about how and where to instal them - did you try that?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Author Comment

by:SadafRasheed
ID: 11818693
i have,,, well i think,,
when i have installed the two exe, one for aspell and other for the dictionary,,
when i run aspell from dos, it works fine,,, one thing i have to go to program files/aspell/bin,,, i doesnot pick the path automatically,, do i have to give the path of dictionary in the autoexec.bat or some thing like that???
also the main server where i'll finally have to run it is running linux,,, and i dont know the path of dictionary,, is there any method to get that info...

0
 
LVL 25

Expert Comment

by:Marcus Bointon
ID: 11818809
Perhaps you should check this out, and perhaps some of the other docs on pspell?

http://www.php.net/manual/en/function.pspell-new-config.php
0
 

Expert Comment

by:Dipak Solanki
ID: 40475268
I have installed pspell on my wamp2.4 and php5.4.16 on my windows server. I have enable dll in php.ini and also place in system32. When I run my php page I got fatal error "Fatal error: Call to undefined function pspell_new()  in php file".

Please suggest or let us know what will be missing to run file.
0
 

Expert Comment

by:Dipak Solanki
ID: 40475280
sphinxsearch extension not working in my wamp2.4 and php5.4 (windows server). I have followed the all steps as mention in below link. Please let us know how to make it working.
http://www.codepursuit.com/?p=392
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can define this $_GET["page"]  variable on my page? 5 32
PHP Undefined Index in HTML Form? 2 31
Php pie charts 3 26
myqsl update statement on phpMyAdmin 8 21
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now