function getConceptTypeFromDescriptionText($abstract) { $matches = array(); $taggesSentenceArr = posTagText($abstract); //printTag($taggesSentenceArr); $counter = 0; reset($taggesSentenceArr); while (current($taggesSentenceArr)) { $currentTagArr = current($taggesSentenceArr); $nextTagArr = next($taggesSentenceArr); if (($currentTagArr['tag'] == "VBZ" || $currentTagArr['tag'] == "VBD") && $nextTagArr['tag'] == "DT") { $thirdTagArr = next($taggesSentenceArr); if (($thirdTagArr['tag'] == "NN" || $thirdTagArr['tag'] == "VBG") && strtolower($thirdTagArr['token']) != "name") { $forthTagArr = next($taggesSentenceArr); if (!empty($forthTagArr) && $forthTagArr['tag'] == "IN") { //echoN("########".$nextTagArr['token']); return $thirdTagArr['token']; } } } if ($counter++ > 20) { return false; } } return false; }
function posTagUserQuery($query, $lang) { $taggedSignificantWords = array(); if ($lang == "EN") { $taggedWordsArr = posTagText($query); foreach ($taggedWordsArr as $posArr) { $word = trim($posArr['token']); $tag = trim($posArr['tag']); // no need for that, removed 'loves'(verb) which is not needed to search ontology verbs //if ( strpos($tag,"NN")!==false || strpos($tag,"NP")!==false ) //{ $taggedSignificantWords[$word] = $tag; //} } } else { //$query = removeStopwordsAndTrim($query,$lang); $tempArr = explode(" ", $query); foreach ($tempArr as $index => $word) { if (isset($MODEL_CORE['STOP_WORDS'][$word])) { ///STOPWORD $taggedSignificantWords[$word] = "STW"; } else { $taggedSignificantWords[$word] = "NN"; } } } return $taggedSignificantWords; }