Example #1
0
require_once "../../phplib/util.php";
$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) {
Example #2
0
<?php

require_once '../../phplib/util.php';
$defIds = file('defIds.txt');
foreach ($defIds as $i => $defId) {
    $defId = trim($defId);
    if (!$defId) {
        continue;
    }
    $def = Definition::load($defId);
    print $i + 1 . "/" . count($defIds) . " {$defId}\n";
    print "{$def->internalRep}\n";
    $newRep = '';
    $len = mb_strlen($def->internalRep);
    for ($i = 0; $i < $len; $i++) {
        $c = text_getCharAt($def->internalRep, $i);
        if ($c == '|') {
            $mid = mb_strpos($def->internalRep, '|', $i + 1);
            $close = mb_strpos($def->internalRep, '|', $mid + 1);
            $text = mb_substr($def->internalRep, $i + 1, $mid - $i - 1);
            $ref = mb_substr($def->internalRep, $mid + 1, $close - $mid - 1);
            print "|{$text}|{$ref}|\n";
            $i = $close;
            $c = readChar();
            if ($c == 'k') {
                $newRep .= "|{$text}|{$ref}|";
            } else {
                if ($c == 'd') {
                    $newRep .= $text;
                }
            }
<?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();
}