Jump to content

PSPELL PROBLEMS!!! Anyone get PSPELL to work on their site?


thepip3r

Recommended Posts

Ok, Windows Server 2003, IIS 6, PHP 5.  I enabled the extension in my PHP.ini, I installed the Aspell program.  I installed the Aspell EN dictionary.  I copied the appropriate Aspell .dll to my PHP, and System32 folders.  I've run a successful Aspell operation from my servers command line in troubleshooting.  I've checked phpinfo() to verify that pspell support is showing "enabled".  Yet, after all of this, whenever I call pspell_new('en'), I get the following error:

[quote]Warning: pspell_new() [function.pspell-new]: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language "en". in E:\war\addBullets.php on line 8[/quote]

When I try to use a sourceforge project for spell checking HTML forms, it throws another error but I can't seem to reproduce it at this time and the above problem might fix the other so if anyone knows what I'm doing wrong, please help.  Here's my code that I got off of the php.net site in trying a spell check function:

[code]function spellcheck ( $string ) {
  $words = preg_split('/[\W]+?/',$string);
  $misspelled = $return = array();
  $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;
}[/code]
Link to comment
Share on other sites

I have not played with pspell for while, it was always so slow that I wrote my own PHP spell check extension for windows, anyway I think you need to look in the aspell dic folder and get the right name for the dictionary to use in pspell_new(), I think it's like US_en  for the United States and UK_en for England. check the dic directory in the root of the aspell install folder for the exact name as I can't remember if I am right or not!

It's en_US (United States) or en_GB (England) or en_CA (Canada)


me!
Link to comment
Share on other sites

Here are the other errors I get...

[code]This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. X-Powered-By: PHP/5.1.4 Expires: Thu, 19 Nov 1981 08:52:00 GMT Pragma: no-cache Cache-control: private Content-type: text/html [/code]

and

[code]Unhandled Error: C:\Program Files\Aspell\dict/en-only.rws: The file "C:\Program Files\Aspell\data/iso8859-1.dat" is not in the proper format. [/code]

I tried both "en_US" and "en_US.multi" and that's when I get the above two errors.  I've also tried psell_new('en','american','','',PSPELL_FAST) and I get the last error most recently listed above.
Link to comment
Share on other sites

Do it like this!

There is a problem with pspell_new(), the path to dict directory is hard coded in the PHP dll, it looks for it in C:/php!

Do this to reset the the path from within the aspell config, (at runtime)! In other words don't use pspell_new()

[code]<?

function spell_check ( $string )
{
$words = preg_split ( '/[\W]+?/', $string );

$misspelled = $return = array ();

/* we use the following (2) functions instead of pspell_new() */

// reset the dictionary path, use ASpell(s) config path

$config = pspell_config_create ( 'en_US', '', '', 'utf-8' );

  $int = pspell_new_config ( $config );

foreach ( $words as $value )
{
if ( ! pspell_check ( $int, $value ) )
{
$misspelled[] = $value;
}
}

foreach ( $misspelled as $value )
{
$return[$value] = pspell_suggest ( $int, $value );
}

return $return;
}

print_r ( spell_check ( 'the hetel was raelly baad' ) );

?>[/code]



me!
Link to comment
Share on other sites

I copied and pasted your code and get the EXACT same two errors as listed before.

[quote]This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. X-Powered-By: PHP/5.1.4 Expires: Thu, 19 Nov 1981 08:52:00 GMT Pragma: no-cache Cache-control: private Content-type: text/html [/quote]
and
[quote]Unhandled Error: C:\Program Files\Aspell\dict/en-only.rws: The file "C:\Program Files\Aspell\data/iso8859-1.dat" is not in the proper format. [/quote]

oh and one more step to add to my troubleshooting, I tried simply uninstalling ASpell and the dictionary files and reinstalled them to no avail; caveat - this shouldn't have worked since the command-line portion is working fine BUT i figured i'd give it a shot anyways...
Link to comment
Share on other sites

In this error:  "Unhandled Error: C:\Program Files\Aspell\dict/en-only.rws: The file "C:\Program Files\Aspell\data/iso8859-1.dat" is not in the proper format."

is it supposed to be reading the file in the last directory with a forward slash instead of a backslash?
Link to comment
Share on other sites

If you look on the ASpell mailing list you will see this error many times!

Quote Kevin

> Unhandled Error: C:\Program Files\Aspell\dict/en-only.rws: The file
> "C:\Program Files\Aspell\data/iso8859-1.
> dat" is not in the proper format.
>
> abnormal program termination
>
> It looks like the directory aspell is looking for is being referenced with
> the wrong type of slash? What do I do about that?

It's actually more likely that the iso8859-1.dat file is corrupted.

Perhaps you downloaded it as 'ASCII' instead of 'BINARY' from an FTP server.

Or maybe it just got munged somewhere somehow.

I'd try to locate another copy of that file, and delete the old one,
then copy the new one into the the data directory!

Trust me it not the slashes

//...

I purposely messed up that file in test I just did, it crashed PHP, then my server, so check that file!

I attached a copy of that file...


me!

[attachment deleted by admin]
Link to comment
Share on other sites

I don't mean to sound like a noob printf because I DO appreciate all you've helped so far but I'm not seeing where you're getting that from the mailing list.  I went to the ASpell website, clicked on the Mailling List link and it sent me to http://savannah.gnu.org/mail/?group=aspell.  From there, I clicked on each link and also ran searches for a myriad of variations of my error in a number of different categories (bugs, support, etc) and didn't get one entry returned.

The files were automagically loaded on my 2K3 server when I ran the install files for either ASpell itself or the ASPell english dictionary.  It was an HTTP download so I'm not sure how the format could've gotten messed up.  Regardless, I downloaded, overwrote, and retried your function to no avail.  same set of errors.  if you could direct me to the location where you were getting that mailing list info, i'd be more than happy to peruse for a fix, i'm just not sure exactly how to get to them.

thanx again for all of the help printf, i sincerely appreciate your continued effort.  =D
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.