// Split into words. If multiple words, add each individual word AND the // name as a whole. $latinWords = split(' ', $latinName); $numWords = count($latinWords); for ($i = 0; $i < $numWords; $i++) { $latinWords[$i] = trim($latinWords[$i]); } if ($numWords > 1) { $latinWords[] = implode('', $latinWords); } foreach ($latinWords as $latinWord) { if (hasDname($words, $latinWord)) { echo " ********** Already contains {$latinWord}\n"; } else { $word = new Word(); $word->dname = text_internalizeDname($latinWord); $word->name = text_wordNameToLatin($word->dname); $word->priority = count($words); $word->definitionId = $id; $words[] = $word; $word->save(); echo " Added {$latinWord} with priority " . $word->priority . "\n"; } } } } function hasDname($words, $dname) { foreach ($words as $word) { if ($word->dname == $dname) { return true;
<?php require_once "../../phplib/util.php"; $lines = file('/home/cata/Desktop/dict.html'); foreach ($lines as $line) { $line = trim($line); $parts = split("=", $line, 2); // Take the first word $dnameArray = split(' ', $parts[0], 2); $dname = text_internalizeDname($dnameArray[0]); $words = Word::loadByDname($dname); if (!count($words)) { print $dname . "\n"; } }
<?php require_once "../../phplib/util.php"; $result = logged_query("select * from words"); $count = 0; while ($row = mysql_fetch_assoc($result)) { $def = $row['def']; // echo "DEF: [$def]\n"; $def = text_internalizeDefinition($def); // echo "INT: [$def]\n"; $htmlDef = text_htmlize($def); // echo "HTM: [$htmlDef]\n"; $dname = text_internalizeDname($row['dname']); // echo "DNM: [$dname]\n"; // TODO: Internalize the dname too, fix dname search logged_query("update words set def = '" . addslashes($def) . "', " . "htmlDef = '" . addslashes($htmlDef) . "', " . "dname = '" . addslashes($dname) . "' " . "where counter = " . $row['counter']); $count++; if ($count % 1000 == 0) { echo "Processed {$count} definitions.\n"; } } echo "Done! Processed {$count} definitions.\n";
<?php require_once "../../phplib/util.php"; $query = "select Id from Definition where Lexicon rlike '[^a-eA-Z]'"; $dbResult = mysql_query($query); while ($row = mysql_fetch_assoc($dbResult)) { $def = Definition::load($row['Id']); $words = Word::loadByDefinitionId($def->id); foreach ($words as $word) { $word->dname = text_internalizeDname($word->dname); $word->name = text_wordNameToLatin($word->dname); $word->save(); } $dnames = Word::joinCommaSeparatedDnames($words); if (count($words)) { $def->lexicon = text_dnameToLexicon($words[0]->dname); } else { print "*********** WARNING: No words for this definition: *******\n"; $def->lexicon = ''; } print "Fixing definition " . $def->id . " / {$dnames}; new Lexicon is " . $def->lexicon . "\n"; $def->save(); }