Пример #1
0
 private function initSpellChecker()
 {
     #	Create a PHPSpellCheck Core Engine Instance ;
     $spellcheckObject = new PHPSpellCheck();
     #	Copy and Paste your license key here.  Buy one onlline at www.phpspellcheck.com
     $spellcheckObject->LicenceKey = "TRIAL";
     #	BASIC SETTINGS
     $spellcheckObject->IgnoreAllCaps = false;
     $spellcheckObject->IgnoreNumeric = true;
     $spellcheckObject->CaseSensitive = false;
     # Set up the file path to the (.dic) dictionaries folder
     $spellcheckObject->DictionaryPath = "spelllib/dictionaries/";
     # Sets the tollerance of the spellchecker to 'unlikely' suggestions. 0=intollerant ... 10=very tollerant
     $spellcheckObject->SuggestionTollerance = 1;
     # Loads a dictionary - you can load more than one at the same time */
     $spellcheckObject->LoadDictionary("English (International)");
     #Add vocabulary to the spellchecer from a text file loaded from the DictionaryPath*/
     $spellcheckObject->LoadCustomDictionary("custom.txt");
     /* Alternative methods to load vocabulary
     		$spellcheckObject -> LoadCustomDictionaryFromURL( $URL );
     		$spellcheckObject ->AddCustomDictionaryFromArray(array("popup","nonsensee"));
     		/*
     
     		/* Ban a list of words which will never be alloed as correct spellings.  Ths is great for filtering profanicy.*/
     $spellcheckObject->LoadCustomBannedWords("language-rules/banned-words.txt");
     /*
     You can also add banned words from an array which you could easily populate from an SQL query
     //$spellcheckObject -> AddBannedWords(array("primary"));
     */
     /* Load a lost of Enforced Corrections from a file.  This allows you to enforce a spelling suggestion for a specific word or acronym.*/
     $spellcheckObject->LoadEnforcedCorrections("language-rules/enforced-corrections.txt");
     /*Load a list of common typing mistakes to fine tune the suggestion performance.*/
     $spellcheckObject->LoadCommonTypos("language-rules/common-mistakes.txt");
     return $spellcheckObject;
 }
Пример #2
0
<?php

#	Create a PHPSpellCheck Instance for the SpellCheckButton Class, SpellAsYouType Class and the Javascript/AJAX API
$spellcheckObject = new PHPSpellCheck();
############# LICENSE ############
#	Copy and Paste your license key here.  Buy one onlline at www.phpspellcheck.com
$spellcheckObject->LicenceKey = "TRIAL";
######### BASIC SETTINGS ##########
$spellcheckObject->IgnoreAllCaps = false;
$spellcheckObject->IgnoreNumeric = false;
$spellcheckObject->CaseSensitive = true;
# Set the tollerance of the spellchecker to 'unlikely' suggestions. 0=intollerant ... 10=very tollerant
$spellcheckObject->SuggestionTollerance = 1.5;
############  FILE SYSTEM  ###########
# Set up the file path to the (.dic) dictionaries folder
$spellcheckObject->DictionaryPath = "../dictionaries/";
# Loads all dictionaries requested by the API */
foreach ($RequestedLangs as $dictionary) {
    $spellcheckObject->LoadDictionary(trim($dictionary));
}
#Add vocabulary to the spellchecker from a text file loaded from the DictionaryPath
$spellcheckObject->LoadCustomDictionary("custom.txt");
/* Alternative methods to load vocabulary
$spellcheckObject -> LoadCustomDictionaryFromURL( $URL );
$spellcheckObject ->AddCustomDictionaryFromArray($array)  // This is great for SQL integration
*/
/* Ban a list of words which will never be allowed as correct spellings.  This is great for filtering profanity.*/
$spellcheckObject->LoadCustomBannedWords("language-rules/banned-words.txt");
/*
You can also add banned words from an array which you could easily populate from an SQL query
//$spellcheckObject -> AddBannedWords(array("veryRudeWord"));