Example #1
0
 function getTitle()
 {
     if ($this->lexem === null) {
         $this->lexem = Lexem::get_by_id($this->lexemeId);
     }
     return $this->lexem ? $this->lexem->formNoAccent : '';
 }
Example #2
0
 function getLexem()
 {
     if ($this->lexem === null) {
         $this->lexem = Lexem::get_by_id($this->lexemId);
     }
     return $this->lexem;
 }
Example #3
0
function associateLongInfinitivesAndParticiples()
{
    $lexems = Lexem::loadUnassociated();
    $numMatched = 0;
    foreach ($lexems as $l) {
        $matched = false;
        $wordlist = WordList::loadByUnaccented($l->unaccented);
        foreach ($wordlist as $wl) {
            if ($wl->inflectionId == 50 || $wl->inflectionId == 52) {
                $verb = Lexem::load($wl->lexemId);
                print "{$l->unaccented} :: {$verb->unaccented}\n";
                $matched = true;
                $ldms = LexemDefinitionMap::loadByLexemId($verb->id);
                foreach ($ldms as $ldm) {
                    $existingLdm = LexemDefinitionMap::load($l->id, $ldm->definitionId);
                    if (!$existingLdm) {
                        $newLdm = LexemDefinitionMap::create($l->id, $ldm->definitionId);
                        $newLdm->save();
                    }
                }
            }
        }
        if ($matched) {
            $numMatched++;
        }
    }
    print "Matched {$numMatched} of " . count($lexems) . " total lexems.\n";
}
Example #4
0
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();
    }
}
Example #5
0
 static function loadRelatedLexems($map)
 {
     $results = array();
     foreach ($map as $type => $lexemIds) {
         if ($type) {
             $results[$type] = Lexem::loadByIds(StringUtil::explode(',', $lexemIds));
         }
     }
     return $results;
 }
/**
 * 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;
}
 public static function associate($lexemId, $definitionId)
 {
     // The definition and the lexem should exist
     $definition = Definition::get_by_id($definitionId);
     $lexem = Lexem::get_by_id($lexemId);
     if (!$definition || !$lexem) {
         return;
     }
     // The association itself should not exist.
     $ldm = Model::factory('LexemDefinitionMap')->where('lexemId', $lexemId)->where('definitionId', $definitionId)->find_one();
     if (!$ldm) {
         $ldm = LexemDefinitionMap::create($lexemId, $definitionId);
         $ldm->save();
     }
 }
Example #8
0
function getNouns($word)
{
    $lexems = Lexem::searchWordlists($word, true);
    $result = array();
    foreach ($lexems as $l) {
        if ($l->modelType == 'M' || $l->modelType == 'F' || $l->modelType == 'N' || $l->modelType == 'A' || $l->modelType == 'MF') {
            $result[] = $l;
        }
    }
    return $result;
}
Example #9
0
if ($fileName) {
    $v = Visual::get_by_path($fileName);
    if (!$v) {
        $v = Visual::createFromFile($fileName);
    }
    util_redirect("?id={$v->id}");
}
$v = Visual::get_by_id($id);
if ($saveButton) {
    $v->lexemeId = $lexemId;
    $v->revised = $revised;
    $v->save();
    util_redirect("?id={$v->id}");
}
if ($addTagButton) {
    $vt = Model::factory('VisualTag')->create();
    $vt->imageId = $v->id;
    $vt->lexemeId = $tagLexemId;
    $vt->label = $tagLabel;
    $vt->textXCoord = $textXCoord;
    $vt->textYCoord = $textYCoord;
    $vt->imgXCoord = $imgXCoord;
    $vt->imgYCoord = $imgYCoord;
    $vt->save();
    util_redirect("?id={$v->id}");
}
SmartyWrap::assign('visual', $v);
SmartyWrap::assign('lexem', Lexem::get_by_id($v->lexemeId));
SmartyWrap::addCss('jqueryui-smoothness', 'jcrop', 'select2', 'jqgrid', 'jqueryui', 'gallery');
SmartyWrap::addJs('jquery', 'jqueryui', 'jcrop', 'visualTag', 'select2', 'select2Dev', 'jqgrid', 'gallery');
SmartyWrap::displayAdminPage('admin/visualTag.tpl');
Example #10
0
    }
}
if ($lexemId) {
    SmartyWrap::assign('paradigmLink', util_getWwwRoot() . "lexem/{$cuv}/{$lexemId}/paradigma");
} else {
    SmartyWrap::assign('paradigmLink', util_getWwwRoot() . "definitie/{$cuv}/paradigma");
}
if ($cuv) {
    $cuv = StringUtil::cleanupQuery($cuv);
}
// Normal search
if ($searchType == SEARCH_INFLECTED) {
    $lexems = Lexem::searchInflectedForms($cuv, $hasDiacritics);
    if (count($lexems) == 0) {
        $cuv_old = StringUtil::tryOldOrthography($cuv);
        $lexems = Lexem::searchInflectedForms($cuv_old, $hasDiacritics);
    }
}
// Maps lexems to arrays of inflected forms (some lexems may lack inflections)
// Also compute the text of the link to the paradigm div,
// which can be 'conjugări', 'declinări' or both
if (!empty($lexems)) {
    $conjugations = false;
    $declensions = false;
    $filtered_lexems = array();
    foreach ($lexems as $l) {
        $lm = $l->getFirstLexemModel();
        // One LexemModel suffices -- they all better have the same modelType.
        $isVerb = $lm->modelType == 'V' || $lm->modelType == 'VT';
        if (TYPE_SHOW_ONLY_VERBS == $type && $isVerb || TYPE_SHOW_NO_VERBS == $type && !$isVerb || !$type) {
            $filtered_lexems[] = $l;
Example #11
0
<?php

require_once "../../phplib/util.php";
util_assertModerator(PRIV_EDIT);
util_assertNotMirror();
$suffix = util_getRequestParameter('suffix');
$submitButton = util_getRequestParameter('submitButton');
if ($submitButton) {
    foreach ($_REQUEST as $name => $modelId) {
        if (StringUtil::startsWith($name, 'lexem_')) {
            $parts = preg_split('/_/', $name);
            assert(count($parts) == 2);
            assert($parts[0] == 'lexem');
            $lexem = Lexem::get_by_id($parts[1]);
            if ($modelId) {
                $parts = preg_split('/_/', $modelId);
                assert(count($parts) == 2);
                $lm = $lexem->getFirstLexemModel();
                $lm->modelType = $parts[0];
                $lm->modelNumber = $parts[1];
                $lm->restriction = util_getRequestParameter('restr_' . $lexem->id);
                $lm->save();
                $lm->regenerateParadigm();
            } else {
                $lexem->comment = util_getRequestParameter('comment_' . $lexem->id);
                $lexem->save();
            }
        }
    }
    util_redirect("bulkLabel.php?suffix={$suffix}");
}
Example #12
0
<?php

require_once "../../phplib/util.php";
header("Content-Type: application/json");
$acEnable = Config::get("search.acEnable");
$acMinChars = Config::get("search.acMinChars");
$acLimit = Config::get("search.acLimit");
$search = util_getRequestParameter('term');
if (!$acEnable || strlen($search) < $acMinChars) {
    return print json_encode(array());
}
$hasDiacritics = session_user_prefers(Preferences::FORCE_DIACRITICS) || StringUtil::hasDiacritics($search);
$search_results = Lexem::searchLike("{$search}%", $hasDiacritics, true, $acLimit);
$clean_results = array_map(function ($rec) {
    return $rec['formNoAccent'];
}, $search_results);
return print json_encode($clean_results);
?>

Example #13
0
$dbResult = mysql_query('select * from lexems where (lexem_model_type = "T") or (lexem_model_type in ("MQ", "FQ", "NQ") and lexem_restriction like "%P%")' . 'order by lexem_neaccentuat');
$found = 0;
while ($row = mysql_fetch_assoc($dbResult)) {
    $lexem = Lexem::createFromDbRow($row);
    $wordLists = WordList::loadByUnaccented($lexem->unaccented);
    $matchingWordLists = array();
    foreach ($wordLists as $wl) {
        if (in_array($wl->inflectionId, $PLURAL_INFLECTIONS) && $wl->lexemId != $lexem->id) {
            $matchingWordLists[] = $wl;
        }
    }
    if (count($matchingWordLists)) {
        $sources = getSourcesForLexem($lexem);
        print "{$lexem->unaccented} {$lexem->modelType}{$lexem->modelNumber}{$lexem->restriction} {$sources} " . "http://dexonline.ro/admin/lexemEdit.php?lexemId={$lexem->id}\n";
        foreach ($matchingWordLists as $wl) {
            $match = Lexem::load($wl->lexemId);
            $sources = getSourcesForLexem($match);
            print "    * {$match->unaccented} {$match->modelType}{$match->modelNumber}{$match->restriction} {$sources}" . "http://dexonline.ro/admin/lexemEdit.php?lexemId={$match->id}\n";
        }
        $found++;
    }
}
print "{$found} lexeme semnalate.\n";
/**************************************************************/
function loadSources()
{
    $sources = Source::loadAllSources();
    $result = array();
    foreach ($sources as $source) {
        $result[$source->id] = $source;
    }
Example #14
0
$dbResult = mysql_query($query);
$fixed = 0;
$prevUnaccented = '';
while (($dbRow = mysql_fetch_assoc($dbResult)) != null) {
    $l = Lexem::createFromDbRow($dbRow);
    if ($prevUnaccented != $l->unaccented) {
        $defs = loadDefinitions($l->id);
        if (count($defs)) {
            $isPart = isParticiple($l);
            $isAdj = isAdjective($defs) || $isPart;
            $isMf = isMfNoun($defs);
            $isN = isNNoun($defs);
            $isM = isMNoun($defs) && !$isMf;
            $femForm = loadFeminineForm($l->id);
            $isF = countDefinitionsByLexicon($femForm);
            $homonyms = Lexem::loadByUnaccented($l->unaccented);
            // Very often, the participle also acts os homonym. This is normal.
            // Report other cases of N because we don't have mapping tables for N.
            if (count($homonyms) == 1 && $isN && $isPart) {
                $isN = false;
            }
            // Report cases which (1) contain a N lexem outside of the above case, OR
            // (2) Do not seem to generate all the M and F forms.
            if (!$isAdj && !$isMf && !($isM && $isF) || $isN) {
                //printLexem($homonyms, $isAdj, $isMf, $isM, $isN, $isF);
            } else {
                $fixed += replaceLexems($homonyms, $isAdj, $isMf, $isM, $isN, $isF, $femForm);
            }
        }
    }
    $prevUnaccented = $l->unaccented;
Example #15
0
<?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);
<?php

require_once "../../phplib/util.php";
util_assertModerator(PRIV_EDIT);
util_assertNotMirror();
$reportId = util_getRequestParameter('report');
switch ($reportId) {
    case 'unassociatedLexems':
        echo count(Lexem::loadUnassociated());
        break;
    case 'unassociatedDefinitions':
        echo Definition::countUnassociated();
        break;
    case 'definitionsWithTypos':
        echo Model::factory('Typo')->select('definitionId')->distinct()->count();
        break;
    case 'temporaryDefinitions':
        echo Definition::countByStatus(ST_PENDING);
        break;
    case 'temporaryLexems':
        echo Model::factory('Lexem')->where('modelType', 'T')->count();
        break;
    case 'lexemsWithComments':
        echo Model::factory('Lexem')->where_not_equal('comment', '')->count();
        break;
    case 'lexemsWithoutAccents':
        echo Model::factory('Lexem')->where_raw("form not rlike '\\''")->where('noAccent', false)->count();
        break;
    case 'wotd':
        echo Model::factory('WordOfTheDay')->count();
        break;
Example #17
0
 public static function searchMultipleWords($words, $hasDiacritics, $sourceId, $exclude_unofficial)
 {
     $defCounts = array();
     foreach ($words as $word) {
         $lexems = Lexem::searchInflectedForms($word, $hasDiacritics);
         if (count($lexems)) {
             $definitions = self::loadForLexems($lexems, $sourceId, $word, $exclude_unofficial);
             foreach ($definitions as $def) {
                 $defCounts[$def->id] = array_key_exists($def->id, $defCounts) ? $defCounts[$def->id] + 1 : 1;
             }
         }
     }
     arsort($defCounts);
     $result = array();
     foreach ($defCounts as $defId => $cnt) {
         if ($cnt >= 2) {
             $d = Definition::get_by_id($defId);
             if ($d) {
                 // Hidden definitions might return null
                 $result[] = $d;
             }
         }
     }
     return $result;
 }
Example #18
0
<?php

require_once "../../phplib/util.php";
$id = util_getRequestParameter('id');
$m = Meaning::get_by_id($id);
$l = Lexem::get_by_id($m->lexemId);
$results = array('lexem' => $l->formNoAccent, 'breadcrumb' => $m->breadcrumb, 'htmlRep' => $m->htmlRep);
print json_encode($results);
    smarty_assign('selectedModelNumber', $modelNumber);
    LocVersion::changeDatabase($locVersion);
    if ($modelNumber == -1) {
        $modelsToDisplay = FlexModel::loadByType($modelType);
    } else {
        $modelsToDisplay = array(Model::factory('FlexModel')->where('modelType', $modelType)->where('number', $modelNumber)->find_one());
    }
    $lexems = array();
    $paradigms = array();
    foreach ($modelsToDisplay as $m) {
        // Load by canonical model, so if $modelType is V, look for a lexem with type V or VT.
        $l = Model::factory('Lexem')->select('Lexem.*')->join('ModelType', 'modelType = code')->where('canonical', $modelType)->where('modelNumber', $m->number)->where('form', $m->exponent)->limit(1)->find_one();
        if ($l) {
            $paradigm = getExistingForms($l->id, $locVersion);
        } else {
            $l = Lexem::create($m->exponent, $modelType, $m->number, '');
            $l->isLoc = true;
            $paradigm = getNewForms($l, $locVersion);
        }
        $lexems[] = $l;
        $paradigms[] = $paradigm;
    }
    smarty_assign('modelsToDisplay', $modelsToDisplay);
    smarty_assign('lexems', $lexems);
    smarty_assign('paradigms', $paradigms);
} else {
    smarty_assign('selectedLocVersion', $locVersions[0]->name);
    // LocVersion::changeDatabase($locVersion);
}
$modelTypes = ModelType::loadCanonical();
$models = FlexModel::loadByType($modelType ? $modelType : $modelTypes[0]->code);
Example #20
0
     $cuv_old = StringUtil::tryOldOrthography($cuv);
     $lexems = Lexem::searchInflectedForms($cuv_old, $hasDiacritics, true);
 }
 if (count($lexems) == 0) {
     $searchType = SEARCH_MULTIWORD;
     $words = preg_split('/[ .-]+/', $cuv);
     if (count($words) > 1) {
         $ignoredWords = array_slice($words, 5);
         $words = array_slice($words, 0, 5);
         $definitions = Definition::searchMultipleWords($words, $hasDiacritics, $sourceId, $exclude_unofficial);
         smarty_assign('ignoredWords', $ignoredWords);
     }
 }
 if (count($lexems) == 0 && empty($definitions)) {
     $searchType = SEARCH_APPROXIMATE;
     $lexems = Lexem::searchApproximate($cuv, $hasDiacritics, true);
     if (count($lexems) == 1) {
         FlashMessage::add("Ați fost redirecționat automat la forma „{$lexems[0]->formNoAccent}”.");
     } else {
         if (!count($lexems)) {
             FlashMessage::add("Niciun rezultat relevant pentru „{$cuv}”.");
         }
     }
 }
 if (count($lexems) == 1 && $cuv != $lexems[0]->formNoAccent) {
     // Convenience redirect when there is only one correct form. We want all pages to be canonical
     $sourcePart = $source ? "-{$source->urlName}" : '';
     session_setVariable('redirect', true);
     session_setVariable('init_word', $cuv);
     util_redirect(util_getWwwRoot() . "definitie{$sourcePart}/{$lexems[0]->formNoAccent}" . ($xml ? '/xml' : ''));
 }
Example #21
0
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.
    $lexems = Lexem::loadByCanonicalModel($mm->modelType, $mm->slaveNumber);
    foreach ($lexems as $l) {
        print "\tRegenerating paradigm for {$l->form} ({$l->modelType}" . "{$l->modelNumber})\n";
        $l->regenerateParadigm();
    }
}
mysql_query('drop table model_mappings');
            }
        }
        // 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);
        }
    }
}
Example #23
0
<?php

require_once '../../phplib/util.php';
assert_options(ASSERT_BAIL, 1);
debug_off();
// First remove all restrictions from 'T' lesems
mysql_query('update lexems set lexem_restriction = "" ' . 'where lexem_model_type = "T"');
$query = "select * from lexems where lexem_id not in " . "(select wl_lexem from wordlist)";
$dbResult = mysql_query($query);
while (($dbRow = mysql_fetch_assoc($dbResult)) != null) {
    $l = Lexem::createFromDbRow($dbRow);
    print "{$l->id} {$l->form}\n";
    $l->regenerateParadigm();
}
Example #24
0
 public function delete()
 {
     if ($this->id) {
         if ($this->hasModelType('VT')) {
             $this->deleteParticiple();
         }
         if ($this->hasModelType('VT') || $this->hasModelType('V')) {
             $this->deleteLongInfinitive();
         }
         LexemDefinitionMap::deleteByLexemId($this->id);
         Meaning::delete_all_by_lexemId($this->id);
         Relation::delete_all_by_lexemId($this->id);
         LexemModel::delete_all_by_lexemId($this->id);
     }
     // Clear the variantOfId field for lexems having $this as main.
     $lexemsToClear = Lexem::get_all_by_variantOfId($this->id);
     foreach ($lexemsToClear as $l) {
         $l->variantOfId = null;
         $l->save();
     }
     parent::delete();
 }
<?php

require_once "../phplib/util.php";
$form = util_getRequestParameter('form');
$locVersion = util_getRequestParameter('locVersion');
$locVersions = pref_getLocVersions();
if ($locVersion && $form) {
    LocVersion::changeDatabase($locVersion);
    $form = StringUtil::cleanupQuery($form);
    smarty_assign('page_title', 'Verificare LOC: ' . $form);
    $ifs = loadLoc($form);
    $lexems = array();
    $inflections = array();
    foreach ($ifs as $if) {
        $lexems[] = Lexem::get_by_id($if->lexemId);
        $inflections[] = Inflection::get_by_id($if->inflectionId);
    }
    smarty_assign('form', $form);
    smarty_assign('selectedLocVersion', $locVersion);
    smarty_assign('ifs', $ifs);
    smarty_assign('lexems', $lexems);
    smarty_assign('inflections', $inflections);
} else {
    smarty_assign('selectedLocVersion', $locVersions[1]->name);
    smarty_assign('page_title', 'Căutare formă flexionară în LOC ' . $form);
}
setlocale(LC_ALL, "ro_RO.utf8");
smarty_assign('locVersions', $locVersions);
smarty_displayCommonPageWithSkin('scrabble-flexiune.ihtml');
function loadLoc($cuv)
{
<?php

require_once "../../phplib/util.php";
ini_set('max_execution_time', '3600');
util_assertModerator(PRIV_LOC);
util_assertNotMirror();
DebugInfo::disable();
$modelType = util_getRequestParameter('modelType');
$modelNumber = util_getRequestParameter('modelNumber');
$deleteButton = util_getRequestParameter('deleteButton');
$model = Model::factory('FlexModel')->where('modelType', $modelType)->where('number', $modelNumber)->find_one();
$lexems = Lexem::loadByCanonicalModel($modelType, $modelNumber);
if ($deleteButton) {
    foreach ($lexems as $lexem) {
        $lexem->modelType = 'T';
        $lexem->modelNumber = '1';
        $lexem->restriction = '';
        $lexem->save();
        $lexem->regenerateParadigm();
    }
    $model->delete();
    util_redirect('../admin/index.php');
    exit;
}
RecentLink::createOrUpdate("Ștergere model: {$model}");
smarty_assign('modelType', $modelType);
smarty_assign('modelNumber', $modelNumber);
smarty_assign('lexems', $lexems);
smarty_assign('recentLinks', RecentLink::loadForUser());
smarty_displayWithoutSkin('flex/deleteModel.ihtml');
        $definition->abbrevReview = count($ambiguousMatches) ? ABBREV_AMBIGUOUS : ABBREV_REVIEW_COMPLETE;
        $definition->save();
        log_userLog("Added definition {$definition->id} ({$definition->lexicon})");
        $ldms = array();
        foreach ($lexemNames as $lexemName) {
            $lexemName = addslashes(AdminStringUtil::formatLexem($lexemName));
            if ($lexemName) {
                $matches = Lexem::loadByExtendedName($lexemName);
                if (count($matches) >= 1) {
                    foreach ($matches as $match) {
                        LexemDefinitionMap::associate($match->id, $definition->id);
                        log_userLog("Associating with lexem {$match->id} ({$match->form})");
                    }
                } else {
                    // Create a new lexem.
                    $lexem = Lexem::create($lexemName, 'T', '1', '');
                    $lexem->save();
                    $lexem->regenerateParadigm();
                    LexemDefinitionMap::associate($lexem->id, $definition->id);
                    log_userLog("Created 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 {
    smarty_assign('sourceId', session_getDefaultContribSourceId());
}
smarty_assign('contribSources', Model::factory('Source')->where('canContribute', true)->order_by_asc('displayOrder')->find_many());
smarty_assign('page_title', 'Contribuie cu definiții');
Example #28
0
                    if ($l->comment) {
                        $l->comment = $value;
                    }
                    break;
                case 'delete':
                case 'deleteConfirm':
                    $deleteMap[$l->id] = array_key_exists($l->id, $deleteMap) ? $deleteMap[$l->id] + 1 : 1;
                    break;
            }
        }
    }
    // Delete lexems
    foreach ($deleteMap as $lId => $value) {
        if ($value == 2) {
            // Checked and confirmed
            $l = Lexem::get_by_id($lId);
            $l->delete();
        }
    }
    // Now save the ones that can be saved and present errors for the others
    foreach ($lexemMap as $id => $l) {
        if (!array_key_exists($id, $errorMap) && !array_key_exists($id, $deleteMap)) {
            $l->save();
            $lm = $l->getFirstLexemModel();
            $lm->save();
            $lm->regenerateParadigm();
        }
    }
}
$deSource = Source::get_by_shortName('DE');
$lexems = Model::factory('Lexem')->table_alias('l')->select('l.*')->distinct()->join('LexemModel', 'l.id = lm.lexemId', 'lm')->join('LexemDefinitionMap', 'l.id = ldm.lexemId', 'ldm')->join('Definition', 'ldm.definitionId = d.id', 'd')->where('d.status', Definition::ST_ACTIVE)->where('d.sourceId', $deSource->id)->where('lm.isLoc', 0)->where_like('l.formNoAccent', "{$prefix}%")->where('l.verifSp', 0)->where_not_equal('lm.modelType', 'SP')->order_by_asc('l.formNoAccent')->limit(100)->find_many();
// This is nowhere near perfect, but it's a decent approximation for starters.
// Gives each lexem a frequency between 0.00 and 1.00
// Stop words defined in stringUtil.php get 1.00
// Other lexems get frequencies distributed uniformly between 0.01 and 1.00 based on their percentile rankings in the full text index.
require_once '../phplib/util.php';
ini_set('max_execution_time', '3600');
ini_set('memory_limit', '256M');
assert_options(ASSERT_BAIL, 1);
log_scriptLog('Running rebuildLexemFrequencies.php.');
log_scriptLog('Setting frequency to 1.00 for manual stop words');
foreach (StringUtil::$STOPWORDS as $sw) {
    $lexems = Lexem::get_all_by_formNoAccent($sw);
    foreach ($lexems as $l) {
        $l->frequency = 1.0;
        $l->save();
    }
}
log_scriptLog("Scanning full text index");
$dbResult = db_execute("select lexemId from FullTextIndex group by lexemId order by count(*)");
$numLexems = $dbResult->rowCount();
$i = 0;
foreach ($dbResult as $row) {
    $lexem = Lexem::get_by_id($row[0]);
    $lexem->frequency = round($i / $numLexems + 0.005, 2);
    $lexem->save();
    $i++;
    if ($i % 10000 == 0) {
        log_scriptLog("{$i} of {$numLexems} labeled");
    }
}
log_scriptLog('rebuildLexemFrequencies.php completed successfully');
<?php

require_once "../../phplib/util.php";
util_assertModerator(PRIV_EDIT);
util_assertNotMirror();
RecentLink::createOrUpdate('Lexeme neasociate');
$lexems = Lexem::loadUnassociated();
SmartyWrap::assign('lexems', $lexems);
SmartyWrap::assign('sectionTitle', 'Lexeme neasociate');
SmartyWrap::assign('sectionCount', count($lexems));
SmartyWrap::assign('recentLinks', RecentLink::loadForUser());
SmartyWrap::displayAdminPage('admin/lexemList.ihtml');