Jump to content


Photo

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


  • Please log in to reply
8 replies to this topic

#1 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 03 October 2006 - 08:10 PM

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:

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


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:

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;
}


#2 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 03 October 2006 - 08:34 PM

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!

#3 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 03 October 2006 - 08:49 PM

Here are the other errors I get...

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

and

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.

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.

#4 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 03 October 2006 - 09:17 PM

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()

<?

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' ) );

?>



me!

#5 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 03 October 2006 - 09:48 PM

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

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

and

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.


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...

#6 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 03 October 2006 - 09:53 PM

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?

#7 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 03 October 2006 - 10:15 PM

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]

#8 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 03 October 2006 - 10:34 PM

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....?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

#9 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 04 October 2006 - 03:25 PM

add-on - if my dictionary file is corrupt, why would a command-line operation for aspell work and not one through PHP?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users