note 73791 added to ref.com
| From: | naveed@php.net | Date: | Sat, 10 Mar 2007 13:24:29 +0000 |
| Subject: | note 73791 added to ref.com | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124302@lists.php.net to get a copy of this message | ||
Here is a spell check implementation that displays the suggestion list for each misspelled word.
<?php
function SpellCheck($input)
{
$word=new COM("word.application") or die("Cannot create Word object");
$word->Visible=false;
$word->WindowState=2;
$word->DisplayAlerts=false;
$doc=$word->Documents->Add();
$doc->Content=$input;
$doc->CheckSpelling();
$result= $doc->SpellingErrors->Count;
if($result!=0)
{
echo "Input text contains misspelled words.\n\n";
for($i=1; $i <= $result; $i++)
{
echo "Original Word: " .$doc->SpellingErrors[$i]->Text."\n";
$list=$doc->SpellingErrors[$i]->GetSpellingSuggestions();
echo "Suggestions: ";
for($j=1; $j <= $list->Count; $j++)
{
$correct=$list->Item($j);
echo $correct->Name.",";
}
echo "\n\n";
}
}
else
{
echo "No spelling mistakes found.";
}
$word->ActiveDocument->Close(false);
$word->Quit();
$word->Release();
$word=null;
}
$str="Hellu world. There is a spellling error in this sentence.";
SpellCheck($str);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 210.2.148.26 (proxied: 172.16.203.4)
----
Manual Page -- http://www.php.net/manual/en/ref.com.php
Edit -- https://master.php.net/note/edit/73791
Del: integrated -- https://master.php.net/note/delete/73791/integrated
Del: useless -- https://master.php.net/note/delete/73791/useless
Del: bad code -- https://master.php.net/note/delete/73791/bad+code
Del: spam -- https://master.php.net/note/delete/73791/spam
Del: non-english -- https://master.php.net/note/delete/73791/non-english
Del: in docs -- https://master.php.net/note/delete/73791/in+docs
Del: other reasons-- https://master.php.net/note/delete/73791
Reject -- https://master.php.net/note/reject/73791
Search -- https://master.php.net/manage/user-notes.php