silverorange Code


NateGoSearch.NateGoSearchPSpellSpellChecker
/NateGoSearch/NateGoSearchPSpellSpellChecker.php at line 19

Class NateGoSearchPSpellSpellChecker

NateGoSearchSpellChecker
└─NateGoSearchPSpellSpellChecker

public class NateGoSearchPSpellSpellChecker
extends NateGoSearchSpellChecker

A spell checker to correct commonly misspelled words and phrases using the pspell extension for PHP.

This class uses the PHP interface to the GNU Aspell library for spell-checking.

Copyright:
2007 silverorange
License:
http://www.gnu.org/copyleft/lesser.html LGPL License 2.1

Constructor Summary

NateGoSearchPSpellSpellChecker(string language)

Creates a new Pspell spell checker.

Method Summary
void

addToPersonalWordList(string word)

Add a word to the personal wordlist.

private string

getBestSuggestion(string misspelling, array suggestions)

Gets the best suggestion of a misspelling from a list of suggestions.

private string

getLowerCaseSuggestion(array suggestions)

Gets the best lower-case suggestion for a word.

array

getMisspellingsInPhrase(string phrase)

Checks each word of a phrase for mispellings.

string

getProperSpelling(string phrase)

Gets a phrase with all its misspelled words corrected.

private string

getSuggestedSpelling(string word)

Checks to see if a word is spelled correctly and if it spelled incorrectly, suggests an alternative spelling.

void

loadCustomContent()

Load the personal wordlist and replacement pairs into the spell checker.

void

setCustomReplacementPairs(mixed filename, string the)

Set the replacement pairs.

void

setCustomWordList(string filename)

Set the custom wordlist.

Methods inherited from NateGoSearch.NateGoSearchSpellChecker
getMisspellingsInPhrase, getProperSpelling

Constructor Detail

/NateGoSearch/NateGoSearchPSpellSpellChecker.php at line 70

NateGoSearchPSpellSpellChecker

public NateGoSearchPSpellSpellChecker(string language)

Creates a new Pspell spell checker

Parameters:
language - the language used by this spell checker. This should be a two-letter ISO 639 language code followed by an optional two digit ISO 3166 country code separated by a dash or underscore. For example, 'en', 'en-CA' and 'en_CA' are valid languages.
Throws:
if the Pspell extension is not available.
if a dictionary in the specified language could not be loaded.

Method Detail

/NateGoSearch/NateGoSearchPSpellSpellChecker.php at line 172

addToPersonalWordList

public void addToPersonalWordList(string word)

Add a word to the personal wordlist

Parameters:
word - the word to add to the list

/NateGoSearch/NateGoSearchPSpellSpellChecker.php at line 270

getBestSuggestion

private string getBestSuggestion(string misspelling, array suggestions)

Gets the best suggestion of a misspelling from a list of suggestions

Parameters:
misspelling - the misspelled word.
suggestions - an array of suggestions.
Returns:
the best suggestion in the set of suggestions. If no suitable suggestion is found, a default word is returned.

/NateGoSearch/NateGoSearchPSpellSpellChecker.php at line 301

getLowerCaseSuggestion

private string getLowerCaseSuggestion(array suggestions)

Gets the best lower-case suggestion for a word

Parameters:
suggestions - an array of suggestions.
Returns:
the best lowercase suggestion for a word or null if no lower case suggestion exists.

/NateGoSearch/NateGoSearchPSpellSpellChecker.php at line 98

getMisspellingsInPhrase

public array getMisspellingsInPhrase(string phrase)

Checks each word of a phrase for mispellings

Parameters:
phrase - the phrase to check.
Returns:
a list of mispelled words in the given phrase. The array is in the form of incorrect => correct.

/NateGoSearch/NateGoSearchPSpellSpellChecker.php at line 130

getProperSpelling

public string getProperSpelling(string phrase)

Gets a phrase with all its misspelled words corrected

Parameters:
phrase - the phrase to correct misspellings in.
Returns:
corrected phrase.

/NateGoSearch/NateGoSearchPSpellSpellChecker.php at line 238

getSuggestedSpelling

private string getSuggestedSpelling(string word)

Checks to see if a word is spelled correctly and if it spelled incorrectly, suggests an alternative spelling

Spell checking ignores case. The best suggestion is considered to be the first suggestion.

Parameters:
word - the word to check.
Returns:
the best suggestion for the correct spelling of the word or null if the word is correct or if no suggested spelling exists.

/NateGoSearch/NateGoSearchPSpellSpellChecker.php at line 151

loadCustomContent

public void loadCustomContent()

Load the personal wordlist and replacement pairs into the spell checker


/NateGoSearch/NateGoSearchPSpellSpellChecker.php at line 216

setCustomReplacementPairs

public void setCustomReplacementPairs(mixed filename, string the)

Set the replacement pairs

Set the replacement pairs by passing the path to the custom word list.

Parameters:
the - path to the custom replacement pairs

/NateGoSearch/NateGoSearchPSpellSpellChecker.php at line 200

setCustomWordList

public void setCustomWordList(string filename)

Set the custom wordlist

Set the custom word list by passing the path to the custom word list.

Parameters:
filename - the path to the custom word list

silverorange Code