Login   Register  
PHP Classes
elePHPant
Icontem

File: example_phrase.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of David Frendin  >  lib_dictionary  >  example_phrase.php  >  Download  
File: example_phrase.php
Role: Example script
Content type: text/plain
Description: Example: Correct an entire phrase
Class: lib_dictionary
Check text spelling with a dictionary in MySQL
Author: By
Last change:
Date: 7 years ago
Size: 1,821 bytes
 

Contents

Class file image Download
<?php
/***************************************************************************
 *   example_phrase.php
 *   Copyright (c) 2007 David Frendin (david.frendin@gmail.com)
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version. See the GNU General Public License
 *   for more details.
 *
 ***************************************************************************/

/***************************************************************************
 *   Example: Phrase
 *   This example will do a basic spell-check of a phrase, and return the frase formated
 *    highlighting (in a discrete way) potential misspellings.
 *
 ***************************************************************************/


/* ___[ Below is example code ]_____________________ */
require_once('mysql4.php');    //from phpbb2
require_once('lib_dictionary.php');

define('DICTIONARY_TABLE''dictionary');

//connect to db
$db = new sql_db('localhost''username''password''table'false);
if(!
$db->db_connect_id)
{
    die(
"Could not connect to the database");
}

$dict = new dictclass();



$phrase "Computers are magnificent tools for the realization of our dreams, but no machine can replace the human sparrk of spirit, compassion, love, and understanding.";    //Louis Gerstner
$phrase2 "The reall danger is not that computers will begin to think like men, but tat men will begin to think like computerrs.";    //Sydney J. Harris
echo $dict->spell_phrase($phrasetrue);
echo 
"\n<p>\n";
echo 
$dict->spell_phrase($phrase2true);
die();

/* ___[ End of example code ]_____________________ */
?>