예제 #1
0
$lines = file('/tmp/rez_bio.txt');
foreach ($lines as $line) {
    $components = split('---', $line);
    if (count($components) != 3) {
        echo "Bad line: {$line}";
        continue;
    }
    $id = trim($components[0]);
    $name = trim(strtolower($components[1]));
    $latinList = trim(strtolower($components[2]));
    if (!is_numeric($id)) {
        echo "Bad id: {$id}\n";
        continue;
    }
    $definition = Definition::load($id);
    $words = Word::loadByDefinitionId($id);
    $nameExists = false;
    foreach ($words as $word) {
        if (strtolower($word->name) == $name) {
            $nameExists = true;
        }
    }
    if (!$nameExists) {
        echo "Name does not match id: {$name}, {$id}";
        continue;
    }
    $dnames = Word::joinCommaSeparatedDnames($words);
    echo "Adding words for {$id} ({$dnames})\n";
    $latinNames = split('\\|', $latinList);
    foreach ($latinNames as $latinName) {
        $latinName = trim($latinName);
예제 #2
0
<?php

require_once "../../phplib/util.php";
$query = "select Id from Definition where Lexicon = '' and Status = 0";
$dbResult = mysql_query($query);
while ($row = mysql_fetch_assoc($dbResult)) {
    $def = Definition::load($row['Id']);
    $words = Word::loadByDefinitionId($def->id);
    $dnames = Word::joinCommaSeparatedDnames($words);
    $def->lexicon = text_dnameToLexicon($words[0]->dname);
    print "Fixing definition " . $def->id . " / {$dnames}; new Lexicon is " . $def->lexicon . "\n";
    $def->save();
}