PHP Spell Checker v1.1

February 16th, 2010 by Dragos Leave a reply »

A new version of PHP Spell Checker is available.
The new feature is checking the spelling with Google’s “Did you mean” feature, so not a big update, but useful non the less.

The syntax is the same:

<?php

// include the class
require_once(dirname(__FILE__)."/../GDYMSpellChecker.class.php");

// instantiate the class
$spellCheck = new GDYMSpellChecker();

$textWithErrors = "PHP: the quik browm fox jumps over the lazi dog lazi today"; // this text has 3 errors
$result = $spellCheck->checkSpelling($textWithErrors, "en-US"); // will return an array with the wrong words with associated suggestions
//$result = $spellCheck->checkSpelling($textWithErrors, "en-US", false); // will return an array with the wrong words without associated suggestions
//print_r($spellCheck->getWarnings());// get all warnings
//print_r($spellCheck->getErrors());// get all errors
if (count($result) == 0) {
	print "Text is OK !<br/>";
} else {
	print "Text has errors !<br/>";
	print "<pre>";
	print_r($result);
}

?>

For further reading about the PHP class [p2p type="id" value="20" text="read this post"].

Download the class from here

VN:F [1.9.22_1171]
Rating: 7.9/10 (14 votes cast)
PHP Spell Checker v1.1, 7.9 out of 10 based on 14 ratings
Advertisement

Comments are closed.