PHP: Pspell Functions - Manual
PHP  
downloads | documentation | faq | getting help | mailing lists | | php.net sites | links | my php.net 
search for in the  
<printer_writepspell_add_to_personal>
view the version of this page
Last updated: Thu, 15 Jul 2004

XCI. Pspell Functions

�vod

These functions allow you to check the spelling of a word and offer suggestions.

Po�adavky

To compile PHP with pspell support, you need the aspell library, available from .

Instalace

If you have the libraries needed add the --with-pspell[=dir] option when compiling PHP.

Note to Win32 Users: win32 support is available only in PHP 4.3.3 and later versions. Also, you must have aspell 0.50 or newer installed. In order to enable this module under Windows, you must copy aspell-15.dll from the bin folder of your aspell installation to a folder where PHP will be able to find it. C:\PHP or the SYSTEM32 folder of your windows machine (Ex: C:\WINNT\SYSTEM32 or C:\WINDOWS\SYSTEM32) are good choices.

Konfigurace b�hu

Toto roz���en� nem� definov�no ��dn� konfigura�n� direktivy.

Typy prost�edk�

Toto roz���en� nem� definov�n ��dn� typ prost�edku (resource).

P�eddefinovan� konstanty

Tyto konstanty jsou definov�ny t�mto roz���en�m a budou k dispozici pouze tehdy, bylo-li roz���en� zkompilov�no spole�n� s PHP nebo dynamicky zavedeno za b�hu.

PSPELL_FAST (integer)

PSPELL_NORMAL (integer)

PSPELL_BAD_SPELLERS (integer)

PSPELL_RUN_TOGETHER (integer)

Obsah
pspell_add_to_personal -- Add the word to a personal wordlist
pspell_add_to_session -- Add the word to the wordlist in the current session
pspell_check -- Check a word
pspell_clear_session -- Clear the current session
pspell_config_create -- Create a config used to open a dictionary
pspell_config_data_dir --  location of language data files
pspell_config_dict_dir --  Location of the main word list
pspell_config_ignore -- Ignore words less than N characters long
pspell_config_mode -- Change the mode number of suggestions returned
pspell_config_personal -- Set a file that contains personal wordlist
pspell_config_repl -- Set a file that contains replacement pairs
pspell_config_runtogether -- Consider run-together words as valid compounds
pspell_config_save_repl -- Determine whether to save a replacement pairs list along with the wordlist
pspell_new_config -- Load a new dictionary with settings based on a given config
pspell_new_personal -- Load a new dictionary with personal wordlist
pspell_new -- Load a new dictionary
pspell_save_wordlist -- Save the personal wordlist to a file
pspell_store_replacement -- Store a replacement pair for a word
pspell_suggest -- Suggest spellings of a word


add a note add a note User Contributed Notes
Pspell Functions
tidd
28-Sep-2004 05:31
In response to csnyder's comment about calling aspell instead of using the aspell or pspell libs:

If you are running a low traffic site this will work fine and it's a good idea.

If, however, you have many customers using your spell checking script, this method does not scale well and you should consider spending the time to make the libs work properly.
sudhakar at mindscapecomputing dot com
13-Jul-2004 11:39
The Following Steps to install Aspell and Pspell to work with PHP

Download these files


Pspell Package

Aspell Package

English Dictionary
for Aspell

untar the files
tar zxvf pspell-.12.2.tar.gz
tar zxvf aspell-0.50.1.tar.gz
tar jxvf aspell-en-0.50-2.tar.bz2

we have to install pspell first:

Get into the pspell-.12.2 directory

# ./configure
# make
# make install

# cd modules
# ./add-modules
# cd ..
# make
# make install

Second we have to install Aspell:
Get into the aspell-0.50.1 directory

# ./configure
# make
# make install

After Sucessfully compiled Apply the Dictionary
Get into the aspell-en-0.50-2 directory

# ./configure

Which should output something like:

Finding Dictionary file location ... /usr/local/lib/aspell
Finding Data file location ... /usr/local/share/aspell

# make
# make install

To Check aspell is working try this example

Create a file test.txt add the line "I am speled wron" and save the file

# aspell check test.txt

from the command line.
after the above example work.

use --with-pspell when compiling PHP
webmaster at script-tease dot net
12-Apr-2004 02:26
Easy way to make a spellchecker:

<?

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

?>
jrweir _a_t_ yahoo
30-Mar-2004 07:15
I had the same problems after following the detailed instructions for installing on windows but was able to solve them by doing the following:

first, I copied all the files in the data directory of the aspell install (ie. C:\Program Files\Aspell\data) to a unix machine and ran dos2unix on all of the files and then copied them back.

second, added this line before the pspell_new("en") call
pspell_config_create("en");

hope this works for you too.
kevina at gnu dot org
12-Jan-2003 10:19
Aspell Author Here.

Since Aspell 0.50, Pspell is no longer used.  It is not necessary to download and install the Pspell package, only Aspell 0.50 (or better) is required.  Aspell now provided a backwards compatibility interface for programs expecting the old Pspell interface (such as PHP).

Even though Aspell now provided a new "Aspell" interface this, the PHP Pspell interface is the one you want to use.  The Aspell PHP interface is the one used with a *very* old version of Aspell as the manual says.

Sorry if this is confusing, but it is not really my fought as I have no control over PHP development.  Eventually a new Aspell interface should be provided for PHP which uses the new Aspell interface provided with Aspell 0.50 but for now the Pspell interface will work just fine.

Note: If you wish to use an older version of Aspell (_before_ 0.50) than both Aspell and Pspell are required.
csnyder at chxo dot com
11-Oct-2002 07:37
As an alternative to mucking about with the compiled-in aspell/pspell functions, which only check word by word, one could write a script that calls aspell as a shell exec to check a whole block of text:


(there is a view-source option)

Not sure about Linux or Windows, but installing aspell on FreeBSD was trivially easy from the ports collection. No doubt such a script could be easily modified to use ispell instead if you'd rather.

<printer_writepspell_add_to_personal>
 Last updated: Thu, 15 Jul 2004
show source | credits | sitemap | contact | advertising | mirror sites 
Copyright © 2001-2004 The PHP Group
All rights reserved.
This unofficial mirror is operated at: /
Last updated: Sun Nov 14 23:09:54 2004 Local time zone must be set--see zic manual page