Example #1
0
/**
 * Change the case of letters in $word to match those in $like
 **/
function matchCase($word, $like)
{
    $len = min(mb_strlen($word), mb_strlen($like));
    for ($i = 0; $i < $len; $i++) {
        $cWord = text_getCharAt($word, $i);
        $cLike = text_getCharAt($like, $i);
        if (text_isUppercase($cLike)) {
            $word = mb_substr($word, 0, $i) . text_unicodeToUpper($cWord) . mb_substr($word, $i + 1);
        } else {
            $word = mb_substr($word, 0, $i) . text_unicodeToLower($cWord) . mb_substr($word, $i + 1);
        }
    }
    return $word;
}
Example #2
0
     if ($lexem) {
         $matchingForm = null;
         foreach ($inflections as $inflId) {
             $wls = WordList::loadByLexemIdInflectionId($lexem->id, $inflId);
             foreach ($wls as $wl) {
                 if (matchesWithAccent($wl->form, $suffix)) {
                     $matchingForm = $wl->form;
                     //print "Matching [{$wl->form}] to [$chunk]\n";
                 }
             }
         }
         if ($matchingForm) {
             $matchingFormImpl = str_replace($GLOBALS['text_explicitAccent'], $GLOBALS['text_accented'], $matchingForm);
             // Convert to uppercase when the suffix itself is uppercase
             if ($suffix == text_unicodeToUpper($suffix)) {
                 $matchingFormImpl = text_unicodeToUpper($matchingFormImpl);
             }
             $newRep .= $matchingFormImpl;
         } else {
             $newRep .= $chunk;
             print "***** http://dexonline.ro/search.php?cuv={$lexem->unaccented} *****\n";
             print "{$rep}\n";
             print "  * Nu știu ce să fac cu [{$chunk}] la poziția {$i}, lexem {$lexem->form}, model {$lexem->modelType}{$lexem->modelNumber}{$lexem->restriction}\n";
         }
     } else {
         $newRep .= $chunk;
     }
 } else {
     $newRep .= $chunk;
 }
 $i = $j - 1;