Exemple #1
0
//print_memory_usage();
//bench_mystem($words, $encoding, PATH_TO_MYSTEM);
bench_porter($words, $encoding);
//bench_enchant($words);
//bench_pspell($words);
//print_memory_usage();
bench_morphy_dict($words, $encoding, $dict_dir, $lang, PHPMORPHY_STORAGE_FILE);
bench_morphy_dict($words, $encoding, $dict_dir, $lang, PHPMORPHY_STORAGE_SHM);
bench_morphy_dict($words, $encoding, $dict_dir, $lang, PHPMORPHY_STORAGE_MEM);
bench_morphy($words, $encoding, $dict_dir, $lang, PHPMORPHY_STORAGE_FILE, false);
bench_morphy($words, $encoding, $dict_dir, $lang, PHPMORPHY_STORAGE_FILE, true);
bench_morphy($words, $encoding, $dict_dir, $lang, PHPMORPHY_STORAGE_SHM, false);
bench_morphy($words, $encoding, $dict_dir, $lang, PHPMORPHY_STORAGE_SHM, true);
//print_memory_usage();
bench_morphy($words, $encoding, $dict_dir, $lang, PHPMORPHY_STORAGE_MEM, false);
bench_morphy($words, $encoding, $dict_dir, $lang, PHPMORPHY_STORAGE_MEM, true);
//file_put_contents(__DIR__ . '/.bench.words.txt', implode(PHP_EOL, $words));
print_memory_usage();
/////////////////////////////////////////////////////////////////
function print_memory_usage()
{
    printf("%dKb allocated\n", memory_get_usage() >> 10);
}
function load_words($filePath, $unique, $fileEncoding)
{
    $contents = @iconv($fileEncoding, 'utf-8', file_get_contents($filePath));
    preg_match_all('/[\\s\\"\']([А-ЯЁа-яё+-]+)/u', file_get_contents($filePath), $result);
    $converted = array_map('trim', $result[0]);
    return $unique ? array_unique($converted) : $converted;
}
function convert_words(&$words, $encoding, $case)
Exemple #2
0
//print_memory_usage();
//bench_mystem($words, $encoding, PATH_TO_MYSTEM);
bench_porter($words, $encoding);
//bench_enchant($words);
//bench_pspell($words);
//print_memory_usage();
bench_morphy_dict($words, $encoding, $dict_dir, $lang, phpMorphy::STORAGE_FILE);
bench_morphy_dict($words, $encoding, $dict_dir, $lang, phpMorphy::STORAGE_SHM);
bench_morphy_dict($words, $encoding, $dict_dir, $lang, phpMorphy::STORAGE_MEM);
bench_morphy($words, $encoding, $dict_dir, $lang, phpMorphy::STORAGE_FILE, false);
bench_morphy($words, $encoding, $dict_dir, $lang, phpMorphy::STORAGE_FILE, true);
bench_morphy($words, $encoding, $dict_dir, $lang, phpMorphy::STORAGE_SHM, false);
bench_morphy($words, $encoding, $dict_dir, $lang, phpMorphy::STORAGE_SHM, true);
//print_memory_usage();
bench_morphy($words, $encoding, $dict_dir, $lang, phpMorphy::STORAGE_MEM, false);
bench_morphy($words, $encoding, $dict_dir, $lang, phpMorphy::STORAGE_MEM, true);
//file_put_contents(__DIR__ . '/.bench.words.txt', implode(PHP_EOL, $words));
print_memory_usage();
/////////////////////////////////////////////////////////////////
function print_memory_usage()
{
    printf("%dKb allocated\n", memory_get_usage() >> 10);
}
function load_words($filePath, $unique, $fileEncoding)
{
    $contents = @iconv($fileEncoding, 'utf-8', file_get_contents($filePath));
    preg_match_all('/[\\s\\"\']([А-ЯЁа-яё+-]+)/u', file_get_contents($filePath), $result);
    $converted = array_map('trim', $result[0]);
    return $unique ? array_unique($converted) : $converted;
}
function convert_words(&$words, $encoding, $case)