PHP php_pspell() (Spell Check Function) Error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

dhaval_83
Forum Newbie
Posts: 16
Joined: Tue Feb 06, 2007 12:28 am

Post by dhaval_83 »

facets wrote:what code or application are using with the php_pspell class?
Do you have any errors in your apache logs?
hi,

i am not getting any errors and i am using Windows Server and IIS.

so please tell me configuration for that...
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

Post by facets »

OK. Let me ask this a different way.
What page are you calling in your browser to get the blank page?

Edit.. Or are you trying to get squirrelspell running?
dhaval_83
Forum Newbie
Posts: 16
Joined: Tue Feb 06, 2007 12:28 am

I am writing the steps now...

Post by dhaval_83 »

Hey guys


i am writing steps what i did to install...

System: Windows, Server: IIS

1. install aspell
2. download dictionary (English)
3. copy aspell-15.dll from /bin directory of aspell and paste it to C:\PHP and C:\WINNT\SYSTEM32\
4. php.ini add extension = php_pspell.dll
5. run Spellcheck.php with
$int = pspell_new("en", "", "", "",(PSPELL_FAST|PSPELL_RUN_TOGETHER));
if (!pspell_check($int, $value))
return true;
else
return false;

but this code is also not working, i am taking the words from textarea one by one and check with this but no result the pspell_new is also not working because if i print something below $int = pspell_new("en", "", "", "",(PSPELL_FAST|PSPELL_RUN_TOGETHER)); like echo "hi"; it doesnt show me "hi" while running page.

please let me know...

thanks
dhaval
dhaval_83
Forum Newbie
Posts: 16
Joined: Tue Feb 06, 2007 12:28 am

Still No answer

Post by dhaval_83 »

Hey

Nobody is here who knows the answer.

very disappointed... :cry:
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

From PHP.NET
Note to Win32 Users: In order for this extension to work, there are DLL files that must be available to the Windows system PATH. See the FAQ titled "How do I add my PHP directory to the PATH on Windows" for information on how to do this. Although copying DLL files from the PHP folder into the Windows system directory also works (because the system directory is by default in the systems PATH), it is not recommended. This extension requires the following files to be in the PATH: aspell-15.dll from the bin folder of the aspell installation.

Win32 support is available only in PHP 4.3.3 and later versions. Also, at least aspell version 0.50 is required.
Unfortunately I have never used pspell with windows so I cannot really help you.
printf
Forum Contributor
Posts: 173
Joined: Wed Jan 12, 2005 5:24 pm

Post by printf »

pspell_new doesn't work correctly on most servers under Windows because like PHP, the Aspell developer thinks because your using Windows you don't know how to set a environment path, so the path and names to the dictionaries are hard-coded into the embedded Aspell configuration file that point to C:\Aspell\, so if you install it anywhere else, Aspell will not find the dictionaries. So instead of using pspell_new(), use pspell_new_config() and add (2) system environment paths to the your system Path string under Environment Variables, (1) that point to the base directory where Aspell is installed (C:\web\services\aspell), and (1) that points to the Aspell bin directory (C:\web\services\aspell\bin). Then do something like this....

Code: Select all

<?php

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

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

	// reset the dictionary path, Aspell will look at the system environment Path
	// anytime pspell_new_config() is called, over-riding the default hard-coded values

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

?>
dhaval_83
Forum Newbie
Posts: 16
Joined: Tue Feb 06, 2007 12:28 am

Post by dhaval_83 »

printf wrote:pspell_new doesn't work correctly on most servers under Windows because like PHP, the Aspell developer thinks because your using Windows you don't know how to set a environment path, so the path and names to the dictionaries are hard-coded into the embedded Aspell configuration file that point to C:\Aspell\, so if you install it anywhere else, Aspell will not find the dictionaries. So instead of using pspell_new(), use pspell_new_config() and add (2) system environment paths to the your system Path string under Environment Variables, (1) that point to the base directory where Aspell is installed (C:\web\services\aspell), and (1) that points to the Aspell bin directory (C:\web\services\aspell\bin). Then do something like this....

Code: Select all

<?php

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

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

	// reset the dictionary path, Aspell will look at the system environment Path
	// anytime pspell_new_config() is called, over-riding the default hard-coded values

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

?>
Hey Buddy

I have done the steps as you told me

now i am getting error like this in you given code.

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

abnormal program termination
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.
Post Reply