/** * Removes all punctuation characters and replaces the * spaces with dashes. * * @param string $str * @retunr string */ public function dashed($str) { $phrase = strip_punct($str); $phrase = trim($phrase); $phrase = strtolower($phrase); return preg_replace("@[ ]+@", "-", $phrase); }
} } return $words; } $text = stripslashes($_REQUEST['text']); // This is to deal with the fact that IE receives two characters (\r, \n) for every line break. // This was throwing off the positions of words to be corrected. The positions were off by // one character for each line break entered in the textarea field. $text = preg_replace("/\r/", "", $text); if ($text) { $xml = '<?xml version="1.0" ?>'; /* $xml = '<?xml-stylesheet type="text/xsl" href="spellchecker.xsl" ?>'; */ $xml .= '<spellcheck>'; $xml .= "<originaltext>{$text}</originaltext>"; $spell_checker = new SpellChecker(); $textwords = strip_punct($text); $textwordsArray = word_list($textwords); $list = ""; foreach ($textwordsArray as $n => $w) { $xml .= "<word>"; $xml .= "<original pos=\"{$w->pos}\" len=\"{$w->len}\">{$w->word}</original>"; if (!$spell_checker->check($w->word)) { $xml .= '<status>-1</status>'; $suggestions = $spell_checker->suggest($w->word); if (sizeof($suggestions) > 0) { $xml .= '<suggestions>'; foreach ($suggestions as $s) { $xml .= "<sugword>{$s}</sugword>"; } $xml .= '</suggestions>'; }