예제 #1
0
function validateLexem($l)
{
    if (!text_validateAlphabet($l->form, LEGAL_LEXEM_CHARACTERS)) {
        die("Illegal characters in form {$l->form}\n");
    }
    if (!in_array($l->modelType, $GLOBALS['modelTypes'])) {
        die("Unknown model type {$l->modelType} for word {$l->form}\n");
    }
    if (!text_validateAlphabet($l->modelNumber, '0123456789')) {
        die("Unknown model number {$l->modelNumber} for word {$l->form}\n");
    }
    if (!text_validateAlphabet($l->restriction, 'SPUIT')) {
        die("Unknown restriction {$l->restriction} for word {$l->form}\n");
    }
}
예제 #2
0
function saveCommonModel($modelType, $modelNumber, $forms, $descr, $inflections)
{
    $model = Model::create($modelType, $modelNumber, $descr);
    $model->save();
    $modelNumber = addslashes($modelNumber);
    $baseForm = '';
    foreach ($forms as $index => $form) {
        $inflectionId = $inflections[$index];
        $variants = normalizeForm($form);
        foreach ($variants as $variantNo => $variant) {
            if (!text_validateAlphabet($variant, LEGAL_WORD_CHARACTERS)) {
                die("Illegal characters in form [{$variant}]\n");
            }
            if (!$variant) {
                // Skip missing inflections
                continue;
            }
            $variant = addslashes($variant);
            if (!$baseForm) {
                $baseForm = $variant;
            }
            //print "[$baseForm]\t[$inflectionId]\t[$variantNo]\t[$variant]\n";
            mysql_query("insert into dmlr_models set model_type = '{$modelType}', " . "model_no = '{$modelNumber}', form = '{$variant}', " . "infl_id = {$inflectionId}, variant = {$variantNo}");
        }
    }
    assert($baseForm != '');
    mysql_query("insert into model_exponents set model_type = '{$modelType}', " . "model_no = '{$modelNumber}', form = '{$baseForm}'");
}
예제 #3
0
 foreach ($results as $row) {
     $form = $row['form'];
     $variant = $row['variant'];
     $inflId = $row['infl_id'];
     $isBaseForm = $row['is_baseform'];
     if ($baseForm && $isBaseForm) {
         die("Incorrect baseform for {$model->modelType}{$model->number}\n");
     }
     if (!$baseForm) {
         $baseForm = $form;
     }
     if (text_contains($baseForm, "'") ^ text_contains($form, "'")) {
         print "Incomplete accents for {$baseForm} => {$form}\n";
     }
     //print "$baseForm=>$form\n";
     if (!text_validateAlphabet($form, "aăâbcdefghiîjklmnopqrsștțuvwxyz'")) {
         die("Illegal characters in form {$form}\n");
     }
     $transforms = text_extractTransforms($baseForm, $form, $model->modelType == 'P');
     assert(count($transforms) >= 2);
     // Split off the last transform: it indicates the accent shift
     $accentShift = array_pop($transforms);
     if ($accentShift != UNKNOWN_ACCENT_SHIFT && $accentShift != NO_ACCENT_SHIFT) {
         $accentedVowel = array_pop($transforms);
     } else {
         $accentedVowel = '';
     }
     //foreach ($transforms as $t) {
     //  print $t->toString() . ' ';
     //}
     //print "$accentShift\n";