function importLexems($srcId, $srcName) { $dbResult = db_execute("select l.*, d.internalRep from Lexem l, LexemDefinitionMap ldm, Definition d where l.id = ldm.lexemId and ldm.definitionId = d.id " . "and d.status = 0 and d.sourceId = {$srcId} and not l.isLoc order by l.formNoAccent"); $rowCount = $dbResult->RowCount(); print "************** Import {$rowCount} lexeme din {$srcName}\n"; while (!$dbResult->EOF) { $internalRep = $dbResult->fields['internalRep']; unset($dbResult->fields['internalRep']); unset($dbResult->fields['16']); $l = new Lexem(); $l->set($dbResult->fields); $dbResult->MoveNext(); print sprintf("%d\t%-20s\t%-60s\t%-50s\n", $l->id, $l->formNoAccent, mb_substr($internalRep, 0, 58), "http://dexonline.ro/lexem/{$l->formNoAccent}/{$l->id}"); $l->isLoc = 1; $l->save(); } }
<?php require_once '../phplib/util.php'; $INFL_LONG_INF = 50; $INFL_PART = 52; $LEXEM_EDIT_URL = 'http://dexonline.ro/admin/lexemEdit.php?lexemId='; $dbResult = db_execute("select * from Lexem where modelType in ('V', 'VT') and isLoc order by formNoAccent"); while (!$dbResult->EOF) { $verb = new Lexem(); $verb->set($dbResult->fields); $dbResult->MoveNext(); $ifs = db_find(new InflectedForm(), "lexemId = {$verb->id} and inflectionId = {$INFL_LONG_INF}"); assert(count($ifs) <= 1); if (count($ifs) == 1) { $longInfForm = $ifs[0]->formNoAccent; $longInfModelNumber = text_endsWith($longInfForm, 'are') ? '113' : '107'; $lexems = db_find(new Lexem(), "formNoAccent = '{$longInfForm}' and modelType = 'F' and modelNumber = '{$longInfModelNumber}'"); if (count($lexems) != 1) { print "I {$longInfForm} are " . count($lexems) . " lexeme corespunzătoare\n"; } foreach ($lexems as $longInf) { if (!$longInf->isLoc) { print "I {$longInf->formNoAccent} nu este în LOC {$LEXEM_EDIT_URL}{$longInf->id}\n"; $longInf->isLoc = 1; $longInf->save(); } } } if ($verb->modelType == 'VT') { $ifs = db_find(new InflectedForm(), "lexemId = {$verb->id} and inflectionId = {$INFL_PART}"); $pm = ParticipleModel::loadByVerbModel($verb->modelNumber);
/** * Remove from LOC all the lexems which * - are associated with definitions from DN or MDN, and * - are not associated with definitions from DEX (all editions), DEX-S, DMLR, DLRM, DOOM or DOOM-2, and * - are not infinitives or participles of lexems in the above sources. **/ require_once '../phplib/util.php'; $goodSourceIds = array(Source::get("shortName = \"DEX '75\"")->id, Source::get("shortName = \"DEX '84\"")->id, Source::get("shortName = \"DEX '96\"")->id, Source::get("shortName = \"DEX '98\"")->id, Source::get("shortName = \"DEX '09\"")->id, Source::get("shortName = 'DEX-S'")->id, Source::get("shortName = 'DMLR'")->id, Source::get("shortName = 'DLRM'")->id, Source::get("shortName = 'DOOM'")->id, Source::get("shortName = 'DOOM 2'")->id); // Select all the LOC lexems associated with definitions from DN / MDN. // Process verbs first because we will need to look at their participles / long infinitives later. $query = "select * from Lexem where isLoc order by Lexem.modelType in ('V', 'VT') desc, Lexem.formNoAccent"; $dbResult = db_execute($query); while (!$dbResult->EOF) { $l = new Lexem(); $l->set($dbResult->fields); $dbResult->MoveNext(); $definitions = Definition::loadByLexemId($l->id); $hasGoodSourceIds = false; $i = 0; while ($i < count($definitions) && !$hasGoodSourceIds) { $hasGoodSourceIds = in_array($definitions[$i]->sourceId, $goodSourceIds); $i++; } if (!$hasGoodSourceIds) { $isDerivative = false; // Check if the lexem is a long infinitive or a participle $verbQuery = "select distinct Lexem.* from Lexem, InflectedForm where Lexem.id = InflectedForm.lexemId and Lexem.isLoc " . "and InflectedForm.formNoAccent = '{$l->formNoAccent}' and InflectedForm.inflectionId in (50, 52)"; $verbs = db_getObjects(new Lexem(), db_execute($verbQuery)); if (count($verbs) && $l->modelType == 'F' && ($l->modelNumber == '107' || $l->modelNumber == '113')) { $isDerivative = true;