$newTweet = preg_replace('/[0-9]*/', '', $newTweet); // Remove URLs $newTweet = preg_replace('((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\\w\\d:#@%/;$()~_?\\+-=\\\\.&]*)', '', $newTweet); // Remove special characters $newTweet = preg_replace('/[^A-Za-z0-9_\\s]/', '', $newTweet); // Remove RT $newTweet = preg_replace('/RT./', '', $newTweet); // Convert tweet to hash for comparison $tweetHash = crc32($newTweet); // Check database for hash $hashCheck = $db->query("SELECT * FROM tweet_hash WHERE hash LIKE '" . $tweetHash . "'"); // If no hash found, tweet has not been checked before if (mysql_num_rows($hashCheck) == 0) { // Store hash in database $db->query("INSERT INTO tweet_hash VALUES('','" . $tweetHash . "')"); // Increase number of checked tweets to calculate average later $numTweets++; // Add tweet to string to be spellchecked $regionTweets = $regionTweets . " " . $newTweet; } } // If numtweets = 0, all tweets were duplicates so no average should be stored if ($numTweets > 0) { // Check spelling and calculate avg number of misspellings $misspellings[$pointIndex] = $spellChecker->reader($regionTweets, false, false) / $numTweets; // Add rate into DB $query = "INSERT INTO literacy_cache VALUES('','" . $pointIndex . "','" . $misspellings[$pointIndex] . "')"; $db->query($query); } $pointIndex++; }
<title>Online dictionary! Written by Reza Salehi</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $dr = new dataReader(); // creating a new instance of the class dataReader. this class gets the inputed context and // uses the class LookupTable to find misspled words. $wrd = ""; $j = 0; $i = 0; $sug = false; $stat = false; if ($_POST["sug"] == '1') { $sug = true; } else { $sug = false; } if ($_POST["stat"] == '1') { $stat = true; } else { $stat = false; } $str = $_POST["str"]; $dr->reader($str, $sug, $stat); ?> <a href="index.htm"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Back</strong></font></a> </body> </html>