require_once "../libs/graph.lib.php"; require_once "../libs/question.answering.lib.php"; $lang = "EN"; $direction = "ltr"; $query = $_GET['q']; // QUERY OVERWRITE BY TEST PAGES if ($isInTestScript) { $query = $testQuery; } $originalQuery = $query; $script = $_GET['script']; if (empty($script)) { $script = "simple"; } ///DETEDCT LANGUAGE //LOCATION SIGNIFICANT if (isArabicString($query)) { $lang = "AR"; $direction = "rtl"; } //echoN(memory_get_peak_usage()); //echoN(time()); loadModels("core,search,qac,ontology", $lang); //echoN(time()); $RESOURCES = getModelEntryFromMemory($lang, "MODEL_CORE", "RESOURCES", ""); $META_DATA = getModelEntryFromMemory($lang, "MODEL_CORE", "META_DATA", ""); $significantWords = array(); //echoN($query);exit; //echoN(memory_get_peak_usage()); //$TRANSLATION_MAP_EN_TO_AR = apc_fetch("WORDS_TRANSLATIONS_EN_AR"); //preprint_r($TRANSLATION_MAP_EN_TO_AR); $isPhraseSearch = false;
# back to www.qurananalysis.com and sufficient credits are given. # # ==================================================================== require_once "../global.settings.php"; include_once "../libs/core.lib.php"; $lang = "AR"; if (isset($_GET['lang'])) { $lang = $_GET['lang']; } loadModels("core", $lang); $text = $_GET['text']; $text = html_entity_decode($text); if (empty($text)) { exit; } if (isArabicString($text)) { $translation = arabicToBuckwalter($text); ?> <div class='buckwalter-trans-result-header'>Buckwalter Transliteration: <b><?php echo $translation; ?> </b> </div> <?php } else { try { $arabicTranslation = buckwalterReverseTransliteration($text); ?> <div class='buckwalter-trans-result-header'>Arabic Presentation: <b><?php echo $arabicTranslation; ?>
# back to www.qurananalysis.com and sufficient credits are given. # # ==================================================================== require_once "../global.settings.php"; require_once "../libs/core.lib.php"; require_once "../libs/search.lib.php"; $lang = "AR"; if (isset($_GET['lang'])) { $lang = $_GET['lang']; } $word = $_GET['word']; $word = html_entity_decode($word); if (empty($word)) { exit; } if (isArabicString($word)) { loadModels("core", "AR"); $lang = "AR"; } else { loadModels("core", "EN"); $lang = "EN"; } $similarWordsArr = getSimilarWords($lang, array($word)); ?> <br> <b>Similar Words (Character Similarity)</b> <ul> <?php $i = 0; foreach ($similarWordsArr as $similarWord => $score) {
function extendQueryWordsByDerivations($taggedSignificantWords, $lang) { foreach ($taggedSignificantWords as $word => $posTag) { // avoid small words, will lead to too many iirelevant derivations if (mb_strlen($word) <= 2) { continue; } if ($lang == "EN") { if ($posTag == "NN") { $plural = $word . "s"; $taggedSignificantWords[$plural] = "{$posTag}" . "S"; } else { if ($posTag == "NNS") { $single = substr($word, 0, -1); $taggedSignificantWords[$single] = substr($posTag, 0, -1); } } } else { $simmlarWords = array(); $qaOntologyConceptsIterator = getAPCIterator("ALL\\/MODEL_QA_ONTOLOGY\\/CONCEPTS\\/.*"); foreach ($qaOntologyConceptsIterator as $conceptsCursor) { $conceptID = getEntryKeyFromAPCKey($conceptsCursor['key']); $mainConceptArr = $conceptsCursor['value']; $conceptLabelAR = $mainConceptArr['label_ar']; $dist = myLevensteinEditDistance($word, $conceptLabelAR); if ($dist <= 5) { $dist = getDistanceByCommonUniqueChars($word, $conceptLabelAR); $simmlarWords[$conceptLabelAR] = $dist; } $i = 1; while (isset($mainConceptArr['synonym_' . $i]) && isArabicString($mainConceptArr['synonym_' . $i])) { $synonym = $mainConceptArr['synonym_' . $i]; $dist = myLevensteinEditDistance($word, $synonym); if ($dist <= 5) { $dist = getDistanceByCommonUniqueChars($word, $synonym); $simmlarWords[$synonym] = $dist; } $i++; } } foreach ($simmlarWords as $conceptWord => $distBySimChars) { $diff = mb_strlen($conceptWord) - mb_strlen($word); $absDiffSize = abs($diff); // $word is bigger if ($diff < 0) { $absDiffSize = abs($diff); $diffStr = getStringDiff($conceptWord, $word); //echoN($diffStr); //حيوان => الحيوانات // the bigger word should not contain space الله => سبيل الله // $diffStr=="الات" for حيوان = الحياوانات if (mb_strpos($word, $conceptWord) !== false && strpos($word, " ") === false && ($diffStr == "ات" || $diffStr == "ال" || $diffStr == "الات")) { //echoN("$word, $conceptWord"); /// convert word to noun plular $taggedSignificantWords[$word] = "NNS"; // concept word is singular $taggedSignificantWords[$conceptWord] = "NN"; } else { if ($diff == 1) { $wordLastCharTrimmed = mb_substr($conceptWord, 0, -1); if ($wordLastCharTrimmed . "ات" == $word) { /// convert word to noun plular $taggedSignificantWords[$word] = "NNS"; /// convert word to noun plular $taggedSignificantWords[$conceptWord] = "NN"; } } } } else { $diffStr = getStringDiff($conceptWord, $word); // الحيوانات => حيوان // the bigger word should not contain space الله => سبيل الله if ($diff != 0 && mb_strpos($conceptWord, $word) !== false && strpos($conceptWord, " ") === false && ($diffStr == "ات" || $diffStr == "ال" || $diffStr == "الات")) { //echoN("$word,$conceptWord"); /// convert word to noun plular $taggedSignificantWords[$conceptWord] = "NNS"; } else { if ($diff == 1) { $wordLastCharTrimmed = mb_substr($word, 0, -1); if ($wordLastCharTrimmed . "ات" == $conceptWord) { /// convert word to noun plular $taggedSignificantWords[$conceptWord] = "NNS"; } } } } } // limit the number of derivations+original terms to 15 $taggedSignificantWords = array_slice($taggedSignificantWords, 0, 10); //arsort($simmlarWords); //preprint_r($taggedSignificantWords); //preprint_r($simmlarWords); //exit; } } //preprint_r($taggedSignificantWords); return $taggedSignificantWords; }