コード例 #1
0
/**
 * Returns a LexemModel for a given word and model. Creates one if one doesn't exist.
 **/
function getLexemModel($form, $modelType, $modelNumber)
{
    // Load by canonical model, so if $modelType is V, look for a lexem with type V or VT.
    $lm = Model::factory('LexemModel')->table_alias('lm')->select('lm.*')->join('Lexem', 'l.id = lm.lexemId', 'l')->join('ModelType', 'modelType = code', 'mt')->where('mt.canonical', $modelType)->where('lm.modelNumber', $modelNumber)->where('l.form', $form)->limit(1)->find_one();
    if ($lm) {
        $lm->loadInflectedFormMap();
    } else {
        $l = Lexem::deepCreate($form, $modelType, $modelNumber);
        $lm = $l->getFirstLexemModel();
        $lm->generateInflectedFormMap();
    }
    return $lm;
}
コード例 #2
0
ファイル: Lexem.php プロジェクト: florinp/dexonline
 public function regenerateLongInfinitive()
 {
     $infl = Inflection::loadLongInfinitive();
     $f107 = FlexModel::get_by_modelType_number('F', '107');
     $f113 = FlexModel::get_by_modelType_number('F', '113');
     // Iterate through all the participle forms of this Lexem
     foreach ($this->getLexemModels() as $lm) {
         $ifs = InflectedForm::get_all_by_lexemModelId_inflectionId($lm->id, $infl->id);
         foreach ($ifs as $if) {
             $model = StringUtil::endsWith($if->formNoAccent, 'are') ? $f113 : $f107;
             $lexem = Model::factory('Lexem')->select('l.*')->table_alias('l')->distinct()->join('LexemModel', 'l.id = lm.lexemId', 'lm')->where('l.formNoAccent', $if->formNoAccent)->where_raw("(lm.modelType = 'T' or (lm.modelType = 'F' and lm.modelNumber = '{$model->number}'))")->find_one();
             if ($lexem) {
                 $infLm = $lexem->getFirstLexemModel();
                 if ($infLm->modelType != 'F' || $infLm->modelNumber != $model->number || $inf->restriction != '') {
                     $infLm->modelType = 'F';
                     $infLm->modelNumber = $model->number;
                     $infLm->restriction = '';
                     if ($this->isLoc() && !$infLm->isLoc) {
                         $infLm->isLoc = true;
                         FlashMessage::add("Lexemul {$lexem->formNoAccent}, care nu era în LOC, a fost inclus automat în LOC.", 'info');
                     }
                     $lexem->deepSave();
                 }
             } else {
                 $lexem = Lexem::deepCreate($if->form, 'F', $model->number, '', $this->isLoc());
                 $lexem->deepSave();
                 // Also associate the new lexem with the same definitions as $this.
                 $ldms = LexemDefinitionMap::get_all_by_lexemId($this->id);
                 foreach ($ldms as $ldm) {
                     LexemDefinitionMap::associate($lexem->id, $ldm->definitionId);
                 }
                 FlashMessage::add("Am creat automat lexemul {$lexem->formNoAccent} (F{$model->number}) și l-am asociat cu toate definițiile verbului.", 'info');
             }
         }
     }
 }
コード例 #3
0
            }
        }
        // procedura de refolosire a lexemului sau de regenerare
        if (count($lexems)) {
            // Reuse existing lexem.
            $lexem = $lexems[0];
            if ($verbose) {
                echo "\t\tReusing lexem {$lexem->id} ({$lexem->form})\n";
            }
        } else {
            if ($verbose) {
                echo "\t\tCreating a new lexem for name {$name}\n";
            }
            if (!$dryrun) {
                // Create a new lexem.
                $lexem = Lexem::deepCreate($name, 'T', '1');
                $lexem->deepSave();
                if ($verbose) {
                    echo "\t\tCreated lexem {$lexem->id} ({$lexem->form})\n";
                }
            }
        }
        // procedura de asociere a definiției cu lexemul de mai sus
        if ($verbose) {
            echo "\t\tAssociate lexem {$name} ({$lexem->id}) to definition ({$definition->id})\n";
        }
        if (!$dryrun) {
            LexemDefinitionMap::associate($lexem->id, $definition->id);
        }
    }
}
コード例 #4
0
    } else {
        $definition = Model::factory('Definition')->create();
        $definition->status = ST_PENDING;
        $definition->userId = session_getUserId();
        $definition->sourceId = $sourceId;
        $definition->internalRep = $def;
        $definition->htmlRep = AdminStringUtil::htmlize($def, $sourceId);
        $definition->lexicon = AdminStringUtil::extractLexicon($definition);
        $definition->abbrevReview = count($ambiguousMatches) ? ABBREV_AMBIGUOUS : ABBREV_REVIEW_COMPLETE;
        $definition->save();
        log_userLog("Added definition {$definition->id} ({$definition->lexicon})");
        foreach ($lexemIds as $lexemId) {
            $lexemId = addslashes(AdminStringUtil::formatLexem($lexemId));
            if (StringUtil::startsWith($lexemId, '@')) {
                // create a new lexem
                $lexem = Lexem::deepCreate(substr($lexemId, 1), 'T', '1');
                $lexem->deepSave();
                LexemDefinitionMap::associate($lexem->id, $definition->id);
                log_userLog("Created lexem {$lexem->id} ({$lexem->form})");
            } else {
                $lexem = Lexem::get_by_id($lexemId);
                LexemDefinitionMap::associate($lexem->id, $definition->id);
                log_userLog("Associating with lexem {$lexem->id} ({$lexem->form})");
            }
        }
        FlashMessage::add('Definiția a fost trimisă. Un moderator o va examina în scurt timp. Vă mulțumim!', 'info');
        util_redirect('contribuie');
    }
} else {
    SmartyWrap::assign('sourceId', session_getDefaultContribSourceId());
}
コード例 #5
0
ファイル: editModel.php プロジェクト: Jobava/mirror-dexonline
require_once "../../phplib/util.php";
ini_set('memory_limit', '512M');
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 = FlexModel::get_by_modelType_number($modelType, $modelNumber);
$exponent = $model->exponent;
$lexem = Lexem::deepCreate($exponent, $modelType, $modelNumber);
$ifs = $lexem->getFirstLexemModel()->generateInflectedForms();
$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');
コード例 #6
0
ファイル: reassocciateDE.php プロジェクト: florinp/dexonline
 }
 // Find or create a lexem with the given form/ID and model
 if (is_numeric($form)) {
     $l = Lexem::get_by_id($form);
     if ($l) {
         $new[] = $l;
     } else {
         $errors[] = "Nu există niciun lexem cu ID-ul {$form}";
     }
 } else {
     $matches = Model::factory('Lexem')->where_any_is([['form' => $form], ['formNoAccent' => $form]], ['form' => '= binary', 'formNoAccent' => '= binary'])->find_many();
     if (count($matches) == 0) {
         if ($modelType) {
             $l = Lexem::deepCreate($form, $modelType, $modelNumber);
         } else {
             $l = Lexem::deepCreate($form, 'I', 3);
         }
         $l->noAccent = strstr($form, "'") === false;
         $new[] = $l;
     } else {
         if (count($matches) == 1) {
             if ($modelType) {
                 $new[] = lexemWithModel($matches[0], $modelType, $modelNumber);
             } else {
                 $new[] = $matches[0];
             }
         } else {
             $msg = "Lexemul [{$chunk}] este ambiguu:";
             foreach ($matches as $m) {
                 $msg .= " {$m} ({$m->id});";
             }