public function delete() { $mds = ModelDescription::get_by_modelId($this->id); foreach ($mds as $md) { $md->delete(); } if ($this->modelType == 'V') { $pm = ParticipleModel::loadByVerbModel($this->number); $pm->delete(); } parent::delete(); }
<?php require_once "../../phplib/util.php"; assert_options(ASSERT_BAIL, 1); debug_off(); $dbResult = mysql_query('select * from model_mappings'); $mms = ModelMapping::populateFromDbResult($dbResult); foreach ($mms as $mm) { print "Creating {$mm->modelType}{$mm->slaveNumber} from " . "{$mm->modelType}{$mm->masterNumber}\n"; $master = Model::loadByTypeNumber($mm->modelType, $mm->masterNumber); // Create the model $slave = Model::create($mm->modelType, $mm->slaveNumber, "Derivat din {$mm->modelType}{$mm->masterNumber}"); $slave->save(); $slave->id = db_getLastInsertedId(); // Clone the model descriptions $mds = ModelDescription::loadByModelId($master->id); foreach ($mds as $md) { $md->id = 0; $md->modelId = $slave->id; $md->save(); } // Clone the participle model if ($mm->modelType == 'V') { $pm = ParticipleModel::loadByVerbModel($mm->masterNumber); $clonePm = ParticipleModel::create($mm->slaveNumber, $pm->participleModel); $clonePm->save(); } // Delete the mapping mysql_query("delete from model_mappings where model_type = " . " '{$mm->modelType}' and slave_no = '{$mm->slaveNumber}'"); // Regenerate the lexems. In theory the paradigm won't change, but we want // to actually see it.
ini_set('max_execution_time', '3600'); util_assertModerator(PRIV_LOC); util_assertNotMirror(); DebugInfo::disable(); $modelType = util_getRequestParameter('modelType'); $modelNumber = util_getRequestParameter('modelNumber'); $previewButton = util_getRequestParameter('previewButton'); $confirmButton = util_getRequestParameter('confirmButton'); $modelType = ModelType::canonicalize($modelType); $inflections = Model::factory('Inflection')->where('modelType', $modelType)->order_by_asc('rank')->find_many(); // Load the original data $model = Model::factory('FlexModel')->where('modelType', $modelType)->where('number', $modelNumber)->find_one(); $exponent = $model->exponent; $lexem = Lexem::create($exponent, $modelType, $modelNumber, ''); $ifs = $lexem->generateParadigm(); $mdMap = ModelDescription::getByModelIdMapByInflectionIdVariantApplOrder($model->id); $forms = array(); foreach ($inflections as $infl) { $forms[$infl->id] = array(); } foreach ($ifs as $if) { $forms[$if->inflectionId][] = array('form' => $if->form, 'isLoc' => $mdMap[$if->inflectionId][$if->variant][0]->isLoc, 'recommended' => $mdMap[$if->inflectionId][$if->variant][0]->recommended); } $participleNumber = $modelType == 'V' ? ParticipleModel::loadByVerbModel($modelNumber)->adjectiveModel : ''; if ($previewButton || $confirmButton) { // Load the new forms and exponent; $newModelNumber = util_getRequestParameter('newModelNumber'); $newExponent = util_getRequestParameter('newExponent'); $newDescription = util_getRequestParameter('newDescription'); $newParticipleNumber = util_getRequestParameter('newParticipleNumber'); $newForms = array();
<?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);
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";