Exemplo n.º 1
0
<?php

require_once '../../phplib/util.php';
assert_options(ASSERT_BAIL, 1);
debug_off();
// Create the Latin model type if it doesn't exist
$model = Model::loadByTypeNumber('I', '2');
if (!$model) {
    print "Creating model I2 for biology terms\n";
    $model = Model::create('I', '2', '', 'termeni biologici');
    $model->save();
    $model->id = db_getLastInsertedId();
    $md = ModelDescription::create($model->id, 84, 0, 0, 1, NO_ACCENT_SHIFT, '');
    $md->save();
}
$dbResult = mysql_query("select * from lexems where lexem_model_type = 'T' " . "order by lexem_neaccentuat");
$seen = 0;
$removed = 0;
$biologyTerms = array('plantă', 'pom', 'arbore', 'arbust', 'bot', 'zool', 'mamifer', 'animal');
while (($dbRow = mysql_fetch_assoc($dbResult)) != null) {
    $l = Lexem::createFromDbRow($dbRow);
    $seen++;
    $defs = Definition::loadByLexemId($l->id);
    $matchingLexicon = false;
    $biology = false;
    $appears = false;
    foreach ($defs as $def) {
        if (str_replace('î', 'â', $def->lexicon) == str_replace('î', 'â', $l->unaccented)) {
            $matchingLexicon = true;
        }
        $rep = text_unicodeToLower($def->internalRep);
Exemplo n.º 2
0
        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";
        // Reverse the transforms array. At the same time, save the transforms.
        $newT = array();
        for ($i = count($transforms) - 1; $i >= 0; $i--) {
            $t = $transforms[$i];
            $newT[] = Transform::createOrLoad($t->from, $t->to);
        }
        $transforms = $newT;
        foreach ($transforms as $i => $t) {
            $md = ModelDescription::create($model->id, $inflId, $variant, $i, $t->id, $accentShift, $accentedVowel);
            $md->save();
        }
    }
    $numModels++;
}
print "{$numModels} models migrated from dmlr_models.\n";