// User-configurable list of allowed HTML tags and attributes. $allowed_html = '<strong><small><p><br><a><b><u><i><img><code><ul><ol><li>'; // Set the max number of suggestions to return at a time. define('MAX_SUGGESTIONS', 10); // Set whether to use a personal dictionary. $usePersonalDict = false; //Set whether users are allowed to update the personal dictionary. $editablePersonalDict = true; // If using a personal dictionary, set the path to it. Default is in the // personal_dictionary subdirectory of the location of spell_checker.php. $path_to_personal_dictionary = dirname(__FILE__) . "/personal_dictionary/personal_dictionary.txt"; // Create and configure a link to the silpa module. $silpaspell_module = silpaspell_create(); switch ($_POST['action']) { case 'spellcheck': spellCheck($_POST['spellText']); break; case 'suggest': getSuggestions($_POST['suggestionText']); break; default: echo "Unknown Action"; break; } /************************************************************* * showSuggestions($word, $id) * * The showSuggestions function creates the list of up to 10 * suggestions to return for the given misspelled word. * * $word - The misspelled word that was clicked on
} else { echo implode(",", $suggestions) . "\n"; } } else { echo "no suggestions\n"; } } function spellCheck($string) { return preg_replace_callback('/\\b(\\w|\')+\\b/', 'spellCheckWord', $string); } $t = null; if (isset($argv[0])) { $t = Title::newFromURL(urldecode($argv[0])); } else { $rp = new RandomPage(); $t = $rp->getRandomTitle(); } echo "Doing {$t->getFullURL()}\n"; $r = Revision::newFromTitle($t); if (!$r) { echo "can't get revision for this bad boy\n"; } $text = $r->getText(); $newtext = WikihowArticleEditor::textify($text, array('remove_ext_links' => 1)); echo "text ...{$newtext}\n\n"; $pspell = pspell_new('en', 'american', '', 'utf-8', PSPELL_FAST); spellCheck($newtext); if ($bad == 0) { echo "No misspellings\n"; }