Beispiel #1
0
    require 'phpMorphy.php';
} else {
    require_once MORPHY_2X_DIR . '/src/common.php';
}
$dict_dir = PHPMORPHY_DIR . '/../dicts/' . $encoding;
$words = load_words($text_file, REMOVE_DUPLICATES, $encoding, $file_encoding);
echo "Total words " . (REMOVE_DUPLICATES ? "(unique)" : '') . " = " . count($words) . PHP_EOL;
//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)
Beispiel #2
0
$text_file = $argv[1];
$encoding = $argc > 2 ? $argv[2] : 'utf-8';
$file_encoding = $argc > 3 ? $argv[3] : 'utf-8';
$lang = 'ru_RU';
$dict_dir = phpMorphy::getDefaultDictsDir($encoding);
$words = load_words($text_file, REMOVE_DUPLICATES, $encoding, $file_encoding);
echo "Total words " . (REMOVE_DUPLICATES ? "(unique)" : '') . " = " . count($words) . PHP_EOL;
//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)