<?php $FROM = array('—', '◊', '♦', '[#Pr.#: -$', '$-]', '„', '”', '@ @'); $TO = array('-', '*', '**', '[#Pr.#: $-', '-$]', '"', '"', ' '); $FROM_REGEXP = array('/@\\(([0-9])\\)([.,]?)@/', '/\\^\\{([0-9])\\}/'); $TO_REGEXP = array('(@$1@)$2', '^$1'); $dex09 = Source::get_by_urlName('dex09'); $defs = Model::factory('Definition')->where('sourceId', $dex09->id)->find_result_set(); $num = count($defs); foreach ($defs as $i => $def) { $def->internalRep = str_replace($FROM, $TO, $def->internalRep); $def->internalRep = preg_replace($FROM_REGEXP, $TO_REGEXP, $def->internalRep); $def->htmlRep = AdminStringUtil::htmlize($def->internalRep, $def->sourceId); $def->save(); if ($i % 1000 == 0) { printf("%d of %d definitions processed\n", $i, $num); } }
<?php require_once __DIR__ . '/../phplib/util.php'; define('SERVER_URL', 'http://localhost/~cata/DEX/wwwbase'); $opts = getopt('', array('user:'******'source:', 'date:')); if (count($opts) != 3) { usage(); } $user = User::get_by_nick($opts['user']); $source = Source::get_by_urlName($opts['source']); $timestamp = strtotime($opts['date']); if (!$user || !$source || !$timestamp) { usage(); } $similarSource = SimilarSource::getSimilarSource($source->id); if (!$similarSource) { usage(); } $defs = Model::factory('Definition')->where('userId', $user->id)->where('sourceId', $source->id)->where_gt('createDate', $timestamp)->where('status', Definition::ST_ACTIVE)->order_by_asc('lexicon')->find_many(); $truePositives = $falsePositives = $trueNegatives = 0; foreach ($defs as $def) { $lexemIds = db_getArray("select distinct lexemId from LexemDefinitionMap where definitionId = {$def->id}"); $similar = $def->loadSimilar($lexemIds, $diffSize); if ($similar) { $correct = ($def->similarSource == 1) == ($diffSize == 0); if ($correct) { if ($def->similarSource) { $truePositives++; } else { $trueNegatives++; }
<?php require_once "../../phplib/util.php"; util_assertModerator(PRIV_EDIT); util_assertNotMirror(); RecentLink::createOrUpdate('Greșeli de tipar'); $sourceClause = ''; $sourceId = 0; $sourceUrlName = util_getRequestParameter('source'); if ($sourceUrlName) { $source = $sourceUrlName ? Source::get_by_urlName($sourceUrlName) : null; $sourceId = $source ? $source->id : 0; $sourceClause = $source ? "sourceId = {$sourceId} and " : ''; SmartyWrap::assign('src_selected', $sourceId); } $defs = Model::factory('Definition')->raw_query("select * from Definition where {$sourceClause} id in (select definitionId from Typo) order by lexicon")->find_many(); SmartyWrap::assign('searchResults', SearchResult::mapDefinitionArray($defs)); SmartyWrap::assign('recentLinks', RecentLink::loadForUser()); SmartyWrap::displayAdminPage('admin/viewTypos.tpl');
<?php $sourceMap = array('der' => Source::get_by_urlName('der'), 'dex' => Source::get_by_urlName('dex'), 'dlrm' => Source::get_by_urlName('dlrm'), 'dmlr' => Source::get_by_urlName('dmlr'), 'doom' => Source::get_by_urlName('doom'), 'nodex' => Source::get_by_urlName('nodex'), 'orto' => Source::get_by_urlName('do')); $lexems = Model::factory('Lexem')->where_not_equal('source', '')->find_many(); $inserted = 0; foreach ($lexems as $l) { $urlNames = explode(',', $l->source); foreach ($urlNames as $urlName) { $source = $sourceMap[$urlName]; assert($source); $ls = Model::factory('LexemSource')->create(); $ls->lexemId = $l->id; $ls->sourceId = $source->id; $ls->save(); $inserted++; } } printf("%d lexems modified, %d lexem sources inserted.\n", count($lexems), $inserted);