Exemple #1
0
function bench_morphy_dict($words, $encoding, $dictDir, $lang, $storage)
{
    $opts = array('storage' => $storage, 'predict_by_suffix' => false, 'predict_by_db' => false);
    $bundle = new phpMorphy_FilesBundle($dictDir, $lang);
    $morphy = new phpMorphy($bundle, $opts);
    echo "Bench phpMorphy - Dict[{$encoding}][{$storage}]: ";
    convert_words($words, $encoding, MB_CASE_UPPER);
    $fsa = $morphy->getCommonMorphier()->getFinder()->getFsa();
    $root = $fsa->getRootTrans();
    $predicted = 0;
    $b = microtime(true);
    foreach ($words as $word) {
        $result = $fsa->walk($root, $word, true);
    }
    $e = microtime(true);
    printf("time = %0.2f sec, words per second = %0.2f, predicted = %d\n", $e - $b, count($words) / ($e - $b), $predicted);
}