function loadLoc($cuv)
{
    $field = StringUtil::hasDiacritics($cuv) ? 'formNoAccent' : 'formUtf8General';
    return Model::factory('InflectedForm')->raw_query("select distinct I.* from InflectedForm I, Lexem L, Model M, ModelDescription MD, ModelType MT " . "where I.lexemId = L.id and L.modelType = MT.code and MT.canonical = M.modelType and L.modelNumber = M.number and M.id = MD.modelId " . "and I.inflectionId = MD.inflectionId and I.variant = MD.variant and MD.applOrder = 0 " . "and I.{$field} = '{$cuv}' and L.isLoc and MD.isLoc order by L.formNoAccent", null)->find_many();
}
示例#2
0
<?php

require_once "../../phplib/util.php";
$query = util_getRequestParameter('query');
$field = StringUtil::hasDiacritics($query) ? 'formNoAccent' : 'formUtf8General';
$dbResults = Model::factory('InflectedForm')->table_alias('iff')->select('iff.id')->select('iff.form')->select('l.form', 'baseForm')->select('lm.modelType')->select('lm.modelNumber')->select('lm.restriction')->select('i.description')->join('LexemModel', ['iff.lexemModelId', '=', 'lm.id'], 'lm')->join('Lexem', ['lm.lexemId', '=', 'l.id'], 'l')->join('Inflection', ['iff.inflectionId', '=', 'i.id'], 'i')->where_like("iff.{$field}", "{$query}%")->order_by_asc('iff.formNoAccent')->limit(20)->find_many();
$resp = array('results' => array());
foreach ($dbResults as $rec) {
    $resp['results'][] = ['id' => $rec->id, 'form' => $rec->form, 'baseForm' => $rec->baseForm, 'model' => "{$rec->modelType}{$rec->modelNumber}{$rec->restriction}", 'inflection' => $rec->description];
}
print json_encode($resp);
示例#3
0
assertEquals('@MÁRE^2,@ $mări,$ s.f.', AdminStringUtil::migrateFormatChars('@MÁRE^2@, $mări$, s.f.'));
assertEquals('@$%spaced% text$@', AdminStringUtil::migrateFormatChars('@$ % spaced % text $@'));
assertEquals('40\\% dolomite', AdminStringUtil::migrateFormatChars('40\\% dolomite'));
assertEquals('40 %dolomite%', AdminStringUtil::migrateFormatChars('40% dolomite%'));
assertEquals('cățel', AdminStringUtil::internalizeWordName("C~A,t'EL"));
assertEquals('ă', AdminStringUtil::internalizeWordName("~~A~~!@#\$%^&*()123456790"));
assertEquals('casă', AdminStringUtil::removeAccents('cásă'));
assertEquals('mama', StringUtil::cleanupQuery("'mama'"));
assertEquals('mama', StringUtil::cleanupQuery('"mama"'));
assertEquals('aăbcdef', StringUtil::cleanupQuery("aăbc<mamă foo bar>def"));
assertEquals('AĂBCDEF', StringUtil::cleanupQuery("AĂBC<MAMĂ FOO BAR>DEF"));
assertEquals('a~abcdef', StringUtil::cleanupQuery("a~abc<mam~a foo bar>def"));
assertEquals('a~ABcdef', StringUtil::cleanupQuery("a~ABc<mam~a foo bar>def"));
assertEquals('1234', StringUtil::cleanupQuery('12&qweasd;34'));
assert(StringUtil::hasDiacritics('mamă'));
assert(!StringUtil::hasDiacritics('mama'));
$def = Model::factory('Definition')->create();
$def->sourceId = 1;
$def->internalRep = 'abcd';
assertEquals('abcd', AdminStringUtil::extractLexicon($def));
$def->internalRep = 'wxyz';
assertEquals('wxyz', AdminStringUtil::extractLexicon($def));
$def->internalRep = 'mamă';
assertEquals('mamă', AdminStringUtil::extractLexicon($def));
assert(StringUtil::hasRegexp('asd[0-9]'));
assert(!StringUtil::hasRegexp('ăâîșț'));
assert(StringUtil::hasRegexp('cop?l'));
assertEquals("like 'cop%l'", StringUtil::dexRegexpToMysqlRegexp('cop*l'));
assertEquals("like 'cop_l'", StringUtil::dexRegexpToMysqlRegexp('cop?l'));
assertEquals("rlike '^(cop[a-z]l)\$'", StringUtil::dexRegexpToMysqlRegexp('cop[a-z]l'));
assertEquals("rlike '^(cop[^a-z]l)\$'", StringUtil::dexRegexpToMysqlRegexp('cop[^a-z]l'));
示例#4
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);
?>

示例#5
0
<?php

// TODO: Convert to Idiorm if this is ever needed again
require_once 'phplib/util.php';
require_once 'phplib/ads/adsModule.php';
require_once 'phplib/ads/diverta/divertaAdsModule.php';
$books = Model::factory('DivertaBook')->order_by_asc('id')->find_many();
$numBooks = count($books);
print "Reindexing {$numBooks} book titles.\n";
foreach ($books as $i => $book) {
    db_execute("delete from diverta_Index where bookId = {$book->id}");
    $hasDiacritics = StringUtil::hasDiacritics($book->title);
    $title = mb_strtolower($book->title);
    $title = str_replace(array(',', '.'), '', $title);
    $titleWords = preg_split("/\\s+/", $title);
    $lexemIds = array();
    foreach ($titleWords as $word) {
        if (!StringUtil::isStopWord($word, $hasDiacritics)) {
            $field = $hasDiacritics ? 'formNoAccent' : 'formUtf8General';
            $wordLexemIds = db_getArray(db_execute("select distinct lexemId from InflectedForm where {$field} = '" . addslashes($word) . "'"));
            foreach ($wordLexemIds as $lexemId) {
                $lexemIds[$lexemId] = true;
            }
        }
    }
    foreach ($lexemIds as $lexemId => $ignored) {
        $index = new DivertaIndex();
        $index->lexemId = $lexemId;
        $index->bookId = $book->id;
        $index->save();
    }
<?php

require_once "../../phplib/util.php";
$lexemName = util_getRequestParameter('lexemName');
if (StringUtil::hasRegexp($lexemName)) {
    $hasDiacritics = StringUtil::hasDiacritics($lexemName);
    $lexems = Lexem::searchRegexp($lexemName, $hasDiacritics, null, true);
} else {
    $lexems = Lexem::loadByExtendedName($lexemName);
}
if (count($lexems) == 1) {
    util_redirect('lexemEdit.php?lexemId=' . $lexems[0]->id);
}
smarty_assign('lexems', $lexems);
smarty_assign('sectionTitle', "Căutare lexem: '{$lexemName}'");
smarty_assign('recentLinks', RecentLink::loadForUser());
smarty_displayWithoutSkin('admin/lexemList.ihtml');