function post($txt) { //initialize(); echo "<big><big>NinjaPoST v0.1</big></big><hr><div align=right>PHP + MySQL implementation of Eric Brill's rule-based Part of Speech Tagger</div><br>"; echo "Input: " . $txt . "<br>"; $txt = tokenizer($txt); $txt = startstatetag($txt); echo "Startstatetagged: " . $txt . "<br>"; $txt = finalstatetag($txt); echo "Finalstatetagged: " . $txt . "<br>"; return $txt; }
/** * Querystringparser * * Parses a querystring into a datastructure * * @param string $query Querystring * @param string &$errors Stringreference to write errors back * @return array parsed querytokens */ function queryparser($query, &$errors) { $query = trim($query); /* // filter forbidden characters if (preg_match('/[^\w \.\(\)"\'*]/',$query)) { $errors .= "Nicht erlaubte Zeichen wurden ignoriert\n"; $query = preg_replace('/[^\w \.\(\)"\'*]/','',$query); } */ $ops = array(); $struct = array(); $tokens = tokenizer($query); // look through tokens while ($current = array_shift($tokens)) { if (preg_match('/^(AND|OR|NOT)$/i', $current)) { // token is operator $ops[] = strtoupper($current); } else { // token is searchword if (!count($ops)) { // empty operator counts as AND $ops[] = 'AND'; } // clean invalid operators $cleanops = cleanoperators($ops, $errors); // check wildcards $wild = ''; if (substr($current, 0, 1) == '*') { $wild .= 'l'; } if (substr($current, -1) == '*') { $wild .= 'r'; } $current = str_replace('*', '', $current); $struct[] = array('ops' => $cleanops, 'token' => $current, 'wildcard' => $wild); $ops = array(); } } return $struct; }
function collectParamsCondition($s_arrayObject) { // 뒤의 조건부분만 만들어 내는 부분입니다 (Select count, Delete 일때 사용) for ($i = 0; $i < count($s_arrayObject); $i++) { $tmpData = tokenizer($s_arrayObject[$i], ",", 4); $fieldType1 = $tmpData[0]; $fieldType2 = $tmpData[1]; $fieldName = $tmpData[2]; $fieldValue = addSingleQuotation($fieldType2, $tmpData[3]); switch ($fieldType1) { case "2": //조건데이터(AND); makeWhereString($fieldType1, $returnData, $fieldName, $fieldValue); break; case "3": //조건데이터(OR); makeWhereString($fieldType1, $returnData, $fieldName, $fieldValue); break; } // end of switch($fieldType1) } // end of for if (strlen($returnData) > 0) { $returnData = "where " . $returnData; } $returnData = $returnData; return $returnData; }
function tokenizer($input) { $input = strtolower($input); $input = strip_tags($input); $input = preg_replace('/\\s+/', ' ', $input); $input = preg_replace('/[^-A_Za-z0-9\\s]/', '', $input); return explode(' ', $input); } $search = $_GET['search']; if (strlen($search) < 1) { echo "No query!"; } else { echo "You searched for <b> {$search} </b> <hr size='1' > </ br > "; mysql_connect($servername, $username, $password); mysql_select_db($dbname); $tokens = tokenizer($search); $count = 0; $result = ""; foreach ($tokens as $token_each) { $count++; if ($count == 1) { $result .= "`title` LIKE '%{$token_each}%'"; } else { $result .= " AND `title` LIKE '%{$token_each}%'"; } } $result = "SELECT `title`, `price` ,`id` FROM `Products_kaymu` WHERE {$result}"; $run = mysql_query($result); $num_rows = mysql_num_rows($run); if ($num_rows == 0) { echo "Sorry no result found";
$atime = explode(" ", $atime); $atime = $atime[1] + $atime[0]; $astarttime = $atime; $fs = get_file_storage(); $file = $fs->get_file_by_id($afile->file_id); $filename = $file->get_filename(); // get file name $arrfilename = explode(".", $filename); $ext = $arrfilename[count($arrfilename) - 1]; // get file extension $l1 = $afile->path[0] . $afile->path[1]; $l2 = $afile->path[2] . $afile->path[3]; $apath = $CFG->dataroot . "/filedir/{$l1}/{$l2}/{$afile->path}"; // get file path // call tokenizer to get plain text and store it in plagiarism_crot_documents $atext = tokenizer($apath, $ext); $atext = mb_substr($atext, 0, 999000); // insert into plagiarism_crot_documents // $docrecord = new object(); $docrecord->crot_submission_id = $afile->id; $docrecord->content = addslashes($atext); $docid = $DB->insert_record('plagiarism_crot_documents', $docrecord); //$content = addslashes($atext); //$query = "INSERT INTO {$CFG->prefix}plagiarism_crot_documents (content, crot_submission_id) VALUES ('$content','$afile->id')"; //mysql_query($query); // $docid = mysql_insert_id(); // fingerprinting - calculate and store the fingerprints into the table $atext = mb_strtolower($atext, "utf-8"); // get f/print $fingerp = array(); $fingerp = GetFingerprint($atext);