예제 #1
0
    }
}
if ($lexemId) {
    SmartyWrap::assign('paradigmLink', util_getWwwRoot() . "lexem/{$cuv}/{$lexemId}/paradigma");
} else {
    SmartyWrap::assign('paradigmLink', util_getWwwRoot() . "definitie/{$cuv}/paradigma");
}
if ($cuv) {
    $cuv = StringUtil::cleanupQuery($cuv);
}
// Normal search
if ($searchType == SEARCH_INFLECTED) {
    $lexems = Lexem::searchInflectedForms($cuv, $hasDiacritics);
    if (count($lexems) == 0) {
        $cuv_old = StringUtil::tryOldOrthography($cuv);
        $lexems = Lexem::searchInflectedForms($cuv_old, $hasDiacritics);
    }
}
// Maps lexems to arrays of inflected forms (some lexems may lack inflections)
// Also compute the text of the link to the paradigm div,
// which can be 'conjugări', 'declinări' or both
if (!empty($lexems)) {
    $conjugations = false;
    $declensions = false;
    $filtered_lexems = array();
    foreach ($lexems as $l) {
        $lm = $l->getFirstLexemModel();
        // One LexemModel suffices -- they all better have the same modelType.
        $isVerb = $lm->modelType == 'V' || $lm->modelType == 'VT';
        if (TYPE_SHOW_ONLY_VERBS == $type && $isVerb || TYPE_SHOW_NO_VERBS == $type && !$isVerb || !$type) {
            $filtered_lexems[] = $l;
예제 #2
0
 public static function searchMultipleWords($words, $hasDiacritics, $sourceId, $exclude_unofficial)
 {
     $defCounts = array();
     foreach ($words as $word) {
         $lexems = Lexem::searchInflectedForms($word, $hasDiacritics);
         if (count($lexems)) {
             $definitions = self::loadForLexems($lexems, $sourceId, $word, $exclude_unofficial);
             foreach ($definitions as $def) {
                 $defCounts[$def->id] = array_key_exists($def->id, $defCounts) ? $defCounts[$def->id] + 1 : 1;
             }
         }
     }
     arsort($defCounts);
     $result = array();
     foreach ($defCounts as $defId => $cnt) {
         if ($cnt >= 2) {
             $d = Definition::get_by_id($defId);
             if ($d) {
                 // Hidden definitions might return null
                 $result[] = $d;
             }
         }
     }
     return $result;
 }