php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40759 pspell_new_personal does not load custom dictionary
Submitted: 2007-03-08 17:13 UTC Modified: 2007-03-14 18:16 UTC
From: david at mytton dot net Assigned:
Status: Not a bug Package: Pspell related
PHP Version: 5.2.1 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: david at mytton dot net
New email:
PHP Version: OS:

 

 [2007-03-08 17:13 UTC] david at mytton dot net
Description:
------------
The personal dictionary does not appear to be used when asking pspell for suggestions.

The same result occurs whether or not custom.dict actually exists. E.g. if I change the filename to customdict no error is output and the output is the same.

I tried this with the latest php_pspell.dll from http://snaps.php.net/win32/php5.2-win32-200703081530.zip

Reproduce code:
---------------
<?php
$spelling = pspell_new_personal('C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\custom.dict', 'en');		
$suggestions = pspell_suggest($spelling, 'bloomsbur');
echo '<pre>'; print_r($suggestions); '</pre>';
?>

custom.dict:

personal_ws-1.1 en 1
bloomsbury

Expected result:
----------------
Array of suggestions including bloomsbury in the suggestions.

Actual result:
--------------
bloomsbury is not in the suggestions list:

Array
(
    [0] => blooms bur
    [1] => blooms-bur
    [2] => blooms
    [3] => Bloom's
    [4] => bloom's
    [5] => bloomers
    [6] => Bloomer
    [7] => bloomer
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-08 17:14 UTC] david at mytton dot net
Corrected typo in summary
 [2007-03-09 10:34 UTC] tony2001@php.net
We'll also need your dictionary to investigate it.
Though I doubt it has something to do with PHP.
If pspell doesn't use your dictionary, it's hardly PHP problem.
 [2007-03-09 19:23 UTC] david at mytton dot net
The pspell dictionary or my custom one? The pspell one is a standard English dictionary downloaded from the Aspell website at http://ftp.gnu.org/gnu/aspell/w32/Aspell-en-0.50-2-3.exe. I included my custom dictionary at the bottom of the reproduce code.
 [2007-03-10 00:11 UTC] tony2001@php.net
Works perfectly fine here, on Linux.
<?php
$spelling = pspell_new_personal('/tmp/.aspell.en.pws', 'en');
$suggestions = pspell_suggest($spelling, 'bloomsbur');
var_dump(print_r($suggestions));
?>
Array
(
    [0] => blooms bur
    [1] => blooms-bur
    [2] => Bloomsbury
    [3] => bloomsbury <--------
    [4] => blooms
    [5] => Bloom's
    [6] => bloom's
)
bool(true)

 [2007-03-10 20:05 UTC] david at mytton dot net
I tested the code on another XP computer and also on my Linux server, all with PHP 5.2.1 and it doesn't seem to work (even with full permissions).

<?php
$spelling = pspell_new_personal('/home/site/public_html/custom.dict', 'en');		
$suggestions = pspell_suggest($spelling, 'bloomsbur');
echo '<pre>'; print_r($suggestions); '</pre>';
?>

david@server1 [/home/site/public_html]# ls -al
...
-rwxrwxrwx   1 site site    32 Mar 10 19:57 custom.dict*
...

Output:
Array
(
    [0] => blooms bur
    [1] => blooms-bur
    [2] => blooms
    [3] => Bloom's
    [4] => bloom's
    [5] => bloomers
    [6] => Bloomer
    [7] => bloomer
)
 [2007-03-12 09:41 UTC] tony2001@php.net
So why is that PHP problem?
You pspell doesn't use your custom dictionary, I don't think PHP can fix it.
 [2007-03-12 13:49 UTC] david at mytton dot net
This is with the bundled library with PHP i.e. php_pspell.dll on Windows. So is that not a PHP problem?
 [2007-03-12 13:55 UTC] tony2001@php.net
>This is with the bundled library with PHP i.e. php_pspell.dll on
Windows. 
>So is that not a PHP problem?
In the previous post you said you also tested in on Linux (but didn't say what was the result).
 [2007-03-12 18:44 UTC] david at mytton dot net
In my comment 10 Mar 8:05pm UTC this is the test on Linux with the output i.e. it is the same result as on Windows - not working.
 [2007-03-12 18:50 UTC] tony2001@php.net
What Pspell/Aspell version are you using?
 [2007-03-12 18:54 UTC] david at mytton dot net
Windows:

Aspell-0.50-3
Aspell-en-0.50-2

Linux:

International Ispell Version 3.1.20 (but really Aspell 0.50.3)
 [2007-03-12 19:03 UTC] tony2001@php.net
Try to update it to the latest stable version and see if this fixes the problem.
 [2007-03-12 19:42 UTC] david at mytton dot net
This is the latest Windows version.
 [2007-03-12 19:50 UTC] tony2001@php.net
I'm talking about Linux.
 [2007-03-13 11:04 UTC] tony2001@php.net
Not reproducible on Windows either.
Check your Aspell install and make sure the dictionary format is correct.
Not PHP problem.
 [2007-03-13 15:28 UTC] david at mytton dot net
I reinstalled Aspell on Windows and am still unable to get it to pick up the custom dictionary. The file format I am using is:

personal_ws-1.1 en 1
bloomsbury

in custom.dict with the code in my original description.
 [2007-03-13 15:45 UTC] tony2001@php.net
As I said, it works fine here both on Linux and Windows.
 [2007-03-13 18:39 UTC] david at mytton dot net
Yeah. So how can we go about fixing this? The pspell_new_personal() function doesn't seem to return any kind of error even if the personal dictionary path provided doesn't exist (error reporting all on etc). Is your personal dictionary in the same format as mine?

custom.dict:

personal_ws-1.1 en 1
bloomsbury
 [2007-03-13 19:15 UTC] tony2001@php.net
>Yeah. So how can we go about fixing this?
First make sure it works for you using Aspell console utilities.

>Is your personal dictionary in the same format as mine? 
It's a copy/paste.
 [2007-03-14 18:06 UTC] david at mytton dot net
I upgraded to Aspell 0.60 which is the latest version for Linux and it works fine now. The bug exists only in the 0.50 version it seems (this is the only version available for Windows).

I also noticed that if the personal dictionary path provided to pspell_new_personal() doesn't exist or isn't accessible, the function does not return any kind of error or warning. For example if I change the permissions of the custom.dict file so the PHP user cannot access it, the function doesn't error but just doesn't make use of the custom dictionary file. Should I submit this as a separate bug?
 [2007-03-14 18:16 UTC] tony2001@php.net
>I upgraded to Aspell 0.60 which is the latest version for Linux and
>it works fine now
So I was right and it's not PHP problem.

>Should I submit this as a separate bug?
pspell_new_personal() just modifies the config used further during processing. 
I'd expect the error to appear either when modifying the config or when using its values. In both cases Pspell doesn't report any error.
So yes, you can submit a report, but to Pspell developers, since we can't fix Pspell.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC