function HanziSort($paramArr) { $arr = array(); foreach ($paramArr as $val) { $key = getFirstWord($val); $arr[$key] = $val; } ksort($arr); return $arr; }
//array to store synonyms retrieved //CLEAN THE QUERY STRING FOR SUGGEST WORDS $queryEntered = $_POST['query']; $cleanedQuery = cleanQuery($queryEntered); //****************************************************************************** //Turn off Warning-reporting for the following warning on CSSERVER: //Warning: file_get_contents() [function.file-get-contents]: // SSL: fatal protocol error in ... //error_reporting(E_ERROR | E_PARSE); error_reporting(0); //****************************************************************************** //****************************************************************************** //IF WORD SUGGESTIONS HAVE BEEN REQUESTED DISPLAY ALTERNATIVES if (isset($_POST['reWrite']) && $_POST['reWrite'] != '') { //ONLY WANT THE FIRST WORD FOR OUR LOOKUP $firstQueryWord = getFirstWord($cleanedQuery); //LOOKUP THE WORD getSynonyms($firstQueryWord, $synonyms); //INCLUDE PHP FUNCTION WHICH CREATES A FORM BASED ON THE SYNONYM ARRAY include 'functions/synonymForm.php'; //RUN FUNCTION TO CREATE FORM OF SYNONYMS listSynonyms($synonyms); } else { //IF REWRITE IS NOT REQUESTED, PROCESS QUERY: //CALL FUNCTIONS TO GET RESULTS FROM SEARCH ENGINES getBlekkoResults($blekkoResultsOrig); //get Blekko getGoogleResults($googleResultsOrig); //get Google getBingResults($bingResultsOrig); //get Bing
* @see https://github.com/FerreroJeremy/DBNary-PHP-Interface */ require_once 'DBNaryInterface.php'; /** * @see https://github.com/neitanod/forceutf8 */ require_once 'Encoding.php'; $db = new DBNaryInterface(); $encode = new Encoding(); $db->setLanguageFrom('french'); $db->setLanguageTo('english'); $db->connect(); $words = extractLinesFromFile('dicos/dico_295065.txt'); foreach ($words as $word) { $word = $encode->toUTF8(trim($word)); $word = getFirstWord(trim($word)); $db->getTranslations(trim($word)); $availableTranslations = $db->getResultInList(); if (!empty($availableTranslations)) { foreach ($availableTranslations as $translation) { writeInFile('dico_from_dbnary.txt', trim($word) . ' @ ' . trim($translation) . chr(10)); } } } /* * *********************** * FUNCTIONS * *********************** */ /** * Return the first token of a string. * @param string $text Text. * @return string Token.
foreach ($results as $r) { if (strtolower($r->getText()) == strtolower($title)) { continue; } if ($r->getNamespace() != NS_MAIN || strpos($r->getText(), "Video/") !== false) { continue; } $a = new Article($r); if ($a->isRedirect()) { continue; } if (in_array(strtolower($r->getText()), $ignore_pages)) { continue; } $first_w_r = getFirstWord($r->getText()); $first_w_p = getFirstWord($phrase); if ($first_w_r == $first_w_p) { #echo "The first words ({$first_w_p}, {$first_w_r}) match for phrase '{$phrase}' and result '{$r->getText()}', skipping...\n"; continue; } else { #echo "({$first_w_p}, {$first_w_r}) DO NOT match for phrase {$phrase} and result {$r->getText()}\n"; } $newresults[] = $r; } # any results? $newlinks = 0; // # of new links linking phrase to title foreach ($newresults as $r) { $numreplace = 0; smartReplace($phrase, $title, $r, &$numreplace); $newlinks += $numreplace;