PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




pspell_new

Name

pspell_new — Creates a link to a Pspell dictionary to be used in subsequent operations.

Synopsis

int pspell_new(language[, spelling][, jargon][, encoding][, pspell_mode]);
string language: Language in which spell checking is to be done
string spelling (optional): Spelling variation to use, if applicable
string jargon (optional): Jargon variation to use, if applicable (see below)
string encoding (optional): Expected encoding of the checked words
int pspell_mode (optional): Mode in which Pspell will check words

Returns

If successful, a positive integer identifier for the Pspell dictionary opened; FALSE if an error occurs

Description

pspell_new() opens the dictionary indicated by its arguments and returns an identifier to be used in later spelling operations.

Use the the language parameter to select the language in which you want to check words. This string must be an ISO 639-1 two-letter language code, optionally followed by an underscore or dash and an additional ISO 3166 two-letter country code. Examples include 'en' (English), 'fi' (Finnish), and 'pt_BR' (Brazilian Portuguese). A complete listing of ISO 639-1 language codes is available on the web site of the Library of Congress Network Development and MARC Standards Office athttp://lcweb.loc.gov/standards/iso639-2/englangn.html(don't let the '639-2' throw you; 639-1 codes are included in the list). You can find a complete listing of ISO 3166 codes at the home page of the ISO 3166/MA Secretariat, athttp://www.din.de/gremien/nas/nabd/iso3166ma/index.html.

In situations where there is more than one accepted spelling of a word within the same language, use the spelling parameter to distinguish which spelling is to be preferred. This is useful if you need to decide between, for instance, 'colour' (Canadian and British English) and 'color' (American English). At the time of this writing, the only values understood for the spelling parameter are 'american', 'canadian', and 'british'.

If two or more different words have the same language and spelling , use the jargon parameter to distinguish between them. This is a fairly specific item, with possible values including, for instance, 'medical', 'xlg', and the like. You will need to know beforehand whether you need or even have given jargon dictionaries; you can use the dictionary location and naming instructions from the beginning of this chapter to find out what jargons are available to you.

encoding selects the encoding in which you expect the word to be used. As of this writing, understood values are 'utf-8', 'iso8859-*', 'koi8-r', 'viscii', 'cp1252', 'machine unsigned 16', and 'machine unsigned 32'.

The final parameter is the mode bitmask option, which allows you to tell Pspell how aggressive to be when searching for suggestions for misspelled words. When the Pspell extension is available in PHP, it makes available some predefined constants for use with this parameter. PSPELL_NORMAL , the default, offers a generally useful list of suggestions; PSPELL_FAST offers fewer suggestions; and PSPELL_BAD_SPELLERS offers the greatest number. The fourth possible value, PSPELL_RUN_TOGETHER , can be ORed with one of the first three to tell Pspell to consider run-together words as valid. However, this only means that pspell_check() will consider the words valid; you still can get a list of suggestions from pspell_suggest() .

Example

Example 1112. Create a link to a Pspell dictionary

/* I want to check spelling in Canadian English, allowing run-together words and
 * giving a large number of suggestions for misspelled words. */
$dictid = pspell_new('en', 'canadian', '', '', PSPELL_BAD_SPELLERS|PSPELL_RUN_TOGETHER);



PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.