pspell_add_to_personal

Add the word to a personal wordlist

说明

bool pspell_add_to_personal ( int $dictionary_link , string $word )

pspell_add_to_personal adds a word to the personal wordlist. If you used pspell_new_config with pspell_config_personal to open the dictionary, you can save the wordlist later with pspell_save_wordlist.

参数

dictionary_link

word
The added word.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 pspell_add_to_personal

<?php
$pspell_config = pspell_config_create("en");
pspell_config_personal($pspell_config, "/var/dictionaries/custom.pws");
$pspell_link = pspell_new_config($pspell_config);

pspell_add_to_personal($pspell_link, "Vlad");
pspell_save_wordlist($pspell_link);
?>

注释

Note:

This function will not work unless you have pspell .11.2 and aspell .32.5 or later.

pspell_add_to_session

Add the word to the wordlist in the current session

说明

bool pspell_add_to_session ( int $dictionary_link , string $word )

pspell_add_to_session adds a word to the wordlist associated with the current session. It is very similar to pspell_add_to_personal

参数

dictionary_link

word
The added word.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

pspell_check

Check a word

说明

bool pspell_check ( int $dictionary_link , string $word )

pspell_check checks the spelling of a word.

参数

dictionary_link

word
The tested word.

返回值

Returns TRUE if the spelling is correct, FALSE if not.

范例

示例 #1 pspell_check Example

<?php
$pspell_link = pspell_new("en");

if (pspell_check($pspell_link, "testt")) {
    echo "This is a valid spelling";
} else {
    echo "Sorry, wrong spelling";
}
?>

pspell_clear_session

Clear the current session

说明

bool pspell_clear_session ( int $dictionary_link )

pspell_clear_session clears the current session. The current wordlist becomes blank, and, for example, if you try to save it with pspell_save_wordlist, nothing happens.

参数

dictionary_link

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 pspell_add_to_personal Example

<?php
$pspell_config = pspell_config_create("en");
pspell_config_personal($pspell_config, "/var/dictionaries/custom.pws");
$pspell_link = pspell_new_config($pspell_config);

pspell_add_to_personal($pspell_link, "Vlad");
pspell_clear_session($pspell_link);
pspell_save_wordlist($pspell_link);    //"Vlad" will not be saved
?>

pspell_config_create

Create a config used to open a dictionary

说明

int pspell_config_create ( string $language [, string $spelling [, string $jargon [, string $encoding ]]] )

Create a config used to open a dictionary.

pspell_config_create has a very similar syntax to pspell_new. In fact, using pspell_config_create immediately followed by pspell_new_config will produce the exact same result. However, after creating a new config, you can also use pspell_config_* functions before calling pspell_new_config to take advantage of some advanced functionality.

For more information and examples, check out inline manual pspell website:» http://aspell.net/.

参数

language
The language parameter is the language code which consists of the two letter ISO 639 language code and an optional two letter ISO 3166 country code after a dash or underscore.

spelling
The spelling parameter is the requested spelling for languages with more than one spelling such as English. Known values are 'american', 'british', and 'canadian'.

jargon
The jargon parameter contains extra information to distinguish two different words lists that have the same language and spelling parameters.

encoding
The encoding parameter is the encoding that words are expected to be in. Valid values are 'utf-8', 'iso8859-*', 'koi8-r', 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned 32'. This parameter is largely untested, so be careful when using.

返回值

Returns a pspell config identifier, or FALSE on error.

范例

示例 #1 pspell_config_create

<?php
$pspell_config = pspell_config_create("en");
pspell_config_personal($pspell_config, "/var/dictionaries/custom.pws");
pspell_config_repl($pspell_config, "/var/dictionaries/custom.repl");
$pspell_link = pspell_new_personal($pspell_config, "en");
?>

pspell_config_data_dir

Location of language data files

说明

bool pspell_config_data_dir ( int $conf , string $directory )

Warning

本函数还未编写文档,仅有参数列表。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

pspell_config_dict_dir

Location of the main word list

说明

bool pspell_config_dict_dir ( int $conf , string $directory )

Warning

本函数还未编写文档,仅有参数列表。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

pspell_config_ignore

Ignore words less than N characters long

说明

bool pspell_config_ignore ( int $dictionary_link , int $n )

pspell_config_ignore should be used on a config before calling pspell_new_config. This function allows short words to be skipped by the spell checker.

参数

dictionary_link

n
Words less than n characters will be skipped.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 pspell_config_ignore

<?php
$pspell_config = pspell_config_create("en");
pspell_config_ignore($pspell_config, 5);
$pspell_link = pspell_new_config($pspell_config);
pspell_check($pspell_link, "abcd");    //will not result in an error
?>

pspell_config_mode

Change the mode number of suggestions returned

说明

bool pspell_config_mode ( int $dictionary_link , int $mode )

pspell_config_mode should be used on a config before calling pspell_new_config. This function determines how many suggestions will be returned by pspell_suggest.

参数

dictionary_link

mode
The mode parameter is the mode in which spellchecker will work. There are several modes available:

  • PSPELL_FAST - Fast mode (least number of suggestions)
  • PSPELL_NORMAL - Normal mode (more suggestions)
  • PSPELL_BAD_SPELLERS - Slow mode (a lot of suggestions)

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 pspell_config_mode Example

<?php
$pspell_config = pspell_config_create("en");
pspell_config_mode($pspell_config, PSPELL_FAST);
$pspell_link = pspell_new_config($pspell_config);
pspell_check($pspell_link, "thecat");
?>

pspell_config_personal

Set a file that contains personal wordlist

说明

bool pspell_config_personal ( int $dictionary_link , string $file )

Set a file that contains personal wordlist. The personal wordlist will be loaded and used in addition to the standard one after you call pspell_new_config. The file is also the file where pspell_save_wordlist will save personal wordlist to.

pspell_config_personal should be used on a config before calling pspell_new_config.

参数

dictionary_link

file
The personal wordlist. If the file does not exist, it will be created. The file should be writable by whoever PHP runs as (e.g. nobody).

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 pspell_config_personal

<?php
$pspell_config = pspell_config_create("en");
pspell_config_personal($pspell_config, "/var/dictionaries/custom.pws");
$pspell_link = pspell_new_config($pspell_config);
pspell_check($pspell_link, "thecat");
?>

注释

Note:

This function will not work unless you have pspell .11.2 and aspell .32.5 or later.

pspell_config_repl

Set a file that contains replacement pairs

说明

bool pspell_config_repl ( int $dictionary_link , string $file )

Set a file that contains replacement pairs.

The replacement pairs improve the quality of the spellchecker. When a word is misspelled, and a proper suggestion was not found in the list, pspell_store_replacement can be used to store a replacement pair and then pspell_save_wordlist to save the wordlist along with the replacement pairs.

pspell_config_repl should be used on a config before calling pspell_new_config.

参数

dictionary_link

file
The file should be writable by whoever PHP runs as (e.g. nobody).

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 pspell_config_repl

<?php
$pspell_config = pspell_config_create("en");
pspell_config_personal($pspell_config, "/var/dictionaries/custom.pws");
pspell_config_repl($pspell_config, "/var/dictionaries/custom.repl");
$pspell_link = pspell_new_config($pspell_config);
pspell_check($pspell_link, "thecat");
?>

注释

Note:

This function will not work unless you have pspell .11.2 and aspell .32.5 or later.

pspell_config_runtogether

Consider run-together words as valid compounds

说明

bool pspell_config_runtogether ( int $dictionary_link , bool $flag )

This function determines whether run-together words will be treated as legal compounds. That is, "thecat" will be a legal compound, although there should be a space between the two words. Changing this setting only affects the results returned by pspell_check; pspell_suggest will still return suggestions.

pspell_config_runtogether should be used on a config before calling pspell_new_config.

参数

dictionary_link

flag
TRUE if run-together words should be treated as legal compounds, FALSE otherwise.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 pspell_config_runtogether

<?php
$pspell_config = pspell_config_create("en");
pspell_config_runtogether($pspell_config, true);
$pspell_link = pspell_new_config($pspell_config);
pspell_check($pspell_link, "thecat");
?>

pspell_config_save_repl

Determine whether to save a replacement pairs list along with the wordlist

说明

bool pspell_config_save_repl ( int $dictionary_link , bool $flag )

pspell_config_save_repl determines whether pspell_save_wordlist will save the replacement pairs along with the wordlist. Usually there is no need to use this function because if pspell_config_repl is used, the replacement pairs will be saved by pspell_save_wordlist anyway, and if it is not, the replacement pairs will not be saved.

pspell_config_save_repl should be used on a config before calling pspell_new_config.

参数

dictionary_link

flag
TRUE if replacement pairs should be saved, FALSE otherwise.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

注释

Note:

This function will not work unless you have pspell .11.2 and aspell .32.5 or later.

pspell_new_config

Load a new dictionary with settings based on a given config

说明

int pspell_new_config ( int $config )

pspell_new_config opens up a new dictionary with settings specified in a config, created with pspell_config_create and modified with pspell_config_* functions. This method provides you with the most flexibility and has all the functionality provided by pspell_new and pspell_new_personal.

参数

config
The config parameter is the one returned by pspell_config_create when the config was created.

返回值

Returns a dictionary link identifier on success, 或者在失败时返回 FALSE.

范例

示例 #1 pspell_new_config

<?php
$pspell_config = pspell_config_create("en");
pspell_config_personal($pspell_config, "/var/dictionaries/custom.pws");
pspell_config_repl($pspell_config, "/var/dictionaries/custom.repl");
$pspell_link = pspell_new_config($pspell_config);
?>

pspell_new_personal

Load a new dictionary with personal wordlist

说明

int pspell_new_personal ( string $personal , string $language [, string $spelling [, string $jargon [, string $encoding [, int $mode = 0 ]]]] )

pspell_new_personal opens up a new dictionary with a personal wordlist. The wordlist can be modified and saved with pspell_save_wordlist, if desired. However, the replacement pairs are not saved. In order to save replacement pairs, you should create a config using pspell_config_create, set the personal wordlist file with pspell_config_personal, set the file for replacement pairs with pspell_config_repl, and open a new dictionary with pspell_new_config.

For more information and examples, check out inline manual pspell website:» http://aspell.net/.

参数

personal
The file where words added to the personal list will be stored. It should be an absolute filename beginning with '/' because otherwise it will be relative to $HOME, which is "/root" for most systems, and is probably not what you want.

language
The language code which consists of the two letter ISO 639 language code and an optional two letter ISO 3166 country code after a dash or underscore.

spelling
The requested spelling for languages with more than one spelling such as English. Known values are 'american', 'british', and 'canadian'.

jargon
Extra information to distinguish two different words lists that have the same language and spelling parameters.

encoding
The encoding that words are expected to be in. Valid values are utf-8, iso8859-*, koi8-r, viscii, cp1252, machine unsigned 16, machine unsigned 32.

mode
The mode in which spellchecker will work. There are several modes available:

  • PSPELL_FAST - Fast mode (least number of suggestions)
  • PSPELL_NORMAL - Normal mode (more suggestions)
  • PSPELL_BAD_SPELLERS - Slow mode (a lot of suggestions)
  • PSPELL_RUN_TOGETHER - Consider run-together words as legal compounds. That is, "thecat" will be a legal compound, although there should be a space between the two words. Changing this setting only affects the results returned by pspell_check; pspell_suggest will still return suggestions.

Mode is a bitmask constructed from different constants listed above. However, PSPELL_FAST, PSPELL_NORMAL and PSPELL_BAD_SPELLERS are mutually exclusive, so you should select only one of them.

返回值

Returns the dictionary link identifier for use in other pspell functions.

范例

示例 #1 pspell_new_personal

<?php
$pspell_link = pspell_new_personal ("/var/dictionaries/custom.pws",
        "en", "", "", "", PSPELL_FAST|PSPELL_RUN_TOGETHER);
?>

pspell_new

Load a new dictionary

说明

int pspell_new ( string $language [, string $spelling [, string $jargon [, string $encoding [, int $mode = 0 ]]]] )

pspell_new opens up a new dictionary and returns the dictionary link identifier for use in other pspell functions.

For more information and examples, check out inline manual pspell website:» http://aspell.net/.

参数

language
The language parameter is the language code which consists of the two letter ISO 639 language code and an optional two letter ISO 3166 country code after a dash or underscore.

spelling
The spelling parameter is the requested spelling for languages with more than one spelling such as English. Known values are 'american', 'british', and 'canadian'.

jargon
The jargon parameter contains extra information to distinguish two different words lists that have the same language and spelling parameters.

encoding
The encoding parameter is the encoding that words are expected to be in. Valid values are 'utf-8', 'iso8859-*', 'koi8-r', 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned 32'. This parameter is largely untested, so be careful when using.

mode
The mode parameter is the mode in which spellchecker will work. There are several modes available:

  • PSPELL_FAST - Fast mode (least number of suggestions)
  • PSPELL_NORMAL - Normal mode (more suggestions)
  • PSPELL_BAD_SPELLERS - Slow mode (a lot of suggestions)
  • PSPELL_RUN_TOGETHER - Consider run-together words as legal compounds. That is, "thecat" will be a legal compound, although there should be a space between the two words. Changing this setting only affects the results returned by pspell_check; pspell_suggest will still return suggestions.

Mode is a bitmask constructed from different constants listed above. However, PSPELL_FAST, PSPELL_NORMAL and PSPELL_BAD_SPELLERS are mutually exclusive, so you should select only one of them.

返回值

Returns the dictionary link identifier on success 或者在失败时返回 FALSE.

范例

示例 #1 pspell_new

<?php
$pspell_link = pspell_new("en", "", "", "",
                           (PSPELL_FAST|PSPELL_RUN_TOGETHER));
?>

pspell_save_wordlist

Save the personal wordlist to a file

说明

bool pspell_save_wordlist ( int $dictionary_link )

pspell_save_wordlist saves the personal wordlist from the current session. The location of files to be saved specified with pspell_config_personal and (optionally) pspell_config_repl.

参数

dictionary_link
A dictionary link identifier opened with pspell_new_personal.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 pspell_add_to_personal

<?php
$pspell_config = pspell_config_create("en");
pspell_config_personal($pspell_config, "/tmp/dicts/newdict");
$pspell_link = pspell_new_config($pspell_config);

pspell_add_to_personal($pspell_link, "Vlad");
pspell_save_wordlist($pspell_link);
?>

注释

Note:

This function will not work unless you have pspell .11.2 and aspell .32.5 or later.

pspell_store_replacement

Store a replacement pair for a word

说明

bool pspell_store_replacement ( int $dictionary_link , string $misspelled , string $correct )

pspell_store_replacement stores a replacement pair for a word, so that replacement can be returned by pspell_suggest later. In order to be able to take advantage of this function, you have to use pspell_new_personal to open the dictionary. In order to permanently save the replacement pair, you have to use pspell_config_personal and pspell_config_repl to set the path where to save your custom wordlists, and then use pspell_save_wordlist for the changes to be written to disk.

参数

dictionary_link
A dictionary link identifier, opened with pspell_new_personal

misspelled
The misspelled word.

correct
The fixed spelling for the misspelled word.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

示例 #1 pspell_store_replacement

<?php
$pspell_config = pspell_config_create("en");
pspell_config_personal($pspell_config, "/var/dictionaries/custom.pws");
pspell_config_repl($pspell_config, "/var/dictionaries/custom.repl");
$pspell_link = pspell_new_config($pspell_config);

pspell_store_replacement($pspell_link, $misspelled, $correct);
pspell_save_wordlist($pspell_link);
?>

注释

Note:

This function will not work unless you have pspell .11.2 and aspell .32.5 or later.

pspell_suggest

Suggest spellings of a word

说明

array pspell_suggest ( int $dictionary_link , string $word )

pspell_suggest returns an array of possible spellings for the given word.

参数

dictionary_link

word
The tested word.

返回值

Returns an array of possible spellings.

范例

示例 #1 pspell_suggest example

<?php
$pspell_link = pspell_new("en");

if (!pspell_check($pspell_link, "testt")) {
    $suggestions = pspell_suggest($pspell_link, "testt");

    foreach ($suggestions as $suggestion) {
        echo "Possible spelling: $suggestion<br />";
    }
}
?>

目录