PHP Classes
Icontem

File: example.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of sam  >  MySQL Spell Checker  >  example.php  
File: example.php
Role: Example script
Content type: text/plain
Description: Example file
Class: MySQL Spell Checker
Spell check texts with a MySQL table as dictionary
 

Contents

Class file image Download
<?php
include 'spell-checker-class.php'// include the spell checker class


$spell_checker = new spell_checker// Creat an instance of spell checker class
// set the info to use when doing things with MySQL
$spell_checker->set_mysql_info ('username''password''database_name');
$spell_checker->db_connect(); // connect to MySQL
 
 
if ($spell_checker->check_word('test')) // find out if test is in the dic
{
  echo 
'Test is in the dic'."\n";
}
else
{
  echo 
'You need a better dic'."\n";
}
 
 
$str 'this is a string with a tiepoo.'."\n";
// get all the words from the string and store them in an array in the class
$spell_checker->get_words_from_str($str);
for(;
$wrong $spell_checker->get_next_wrong_word();)
{
  echo 
'This word from the var str is wrong:' $wrong "\n";
}
 
echo 
$spell_checker->replace_all($str); // replace all the wrong words in $str
 
echo 'the words in the array below have a soundex like the word test'."\n";
print_r($spell_checker->suggest('test'));
 
$spell_checker->close_db(); // close db link
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products