示例#1
0
var_dump(MorfFindGroup('ДЕЛ'));
var_dump(MorfFindGroup('ДЕЛА'));
var_dump(MorfFindGroup('ДЕЛО'));
var_dump(MorfFindGroup('ДЕЛОМ'));
var_dump(MorfFindGroup('ДЕНЬ'));
var_dump(MorfFindGroup('ДЕНУ'));
var_dump(MorfFindGroup('ДЕЛИ'));
include 'HStem.php';
$st = microtime(true);
for ($i = 0; $i < 10000; $i++) {
    MorfFindHash('СОЛЬ');
    MorfFindHash('СОЛИ');
    MorfFindHash('ДЕЛИ');
    MorfFindHash('ДЕЛИТЬ');
    MorfFindHash('asdsadsds');
}
echo '<br />MorfFindHash: ' . (microtime(true) - $st) . ' ';
echo 5 * 10000 / (microtime(true) - $st);
echo '<br />';
$st = microtime(true);
for ($i = 0; $i < 10000; $i++) {
    MorfFindGroup('СОЛЬ');
    MorfFindGroup('СОЛИ');
    MorfFindGroup('ДЕЛИ');
    MorfFindGroup('ДЕЛИТЬ');
    MorfFindGroup('asdsadsds');
}
echo '<br />MorfFindGroup: ' . (microtime(true) - $st) . ' ';
echo 5 * 10000 / (microtime(true) - $st);
echo '<br />';
exit;
示例#2
0
 static function morf($str)
 {
     static $cache = array();
     if ($str[0] === '!') {
         return $str;
     }
     if (isset($cache[$str])) {
         return $cache[$str];
     }
     $res = null;
     if (!hq::$noMorf) {
         $res = MorfFindGroup(hq::Cp1251_To_Utf8($str));
     }
     //echo 'omo_id('.$str.')='.$res.' ';
     static $stemmer = null;
     if ($stemmer === null) {
         $stemmer = new LinguaStemRu();
     }
     $res = $res ? $res : $stemmer->stem_word($str);
     $cache[$str] = $res;
     return $res;
 }