Php、enchant库、如何选择字典(如aspell或myspell)
我正在尝试魔法库 我有一个很好用的脚本,但是我可以在几个字典中选择(Aspell或Myspell) 所以,当我尝试这个函数enchant_broker_set_dict_path时,它似乎没有任何效果。 这个函数不在phpdoc中,为什么 在linux上试用,使用PHP5.3 这是我的剧本Php、enchant库、如何选择字典(如aspell或myspell),php,aspell,enchant,Php,Aspell,Enchant,我正在尝试魔法库 我有一个很好用的脚本,但是我可以在几个字典中选择(Aspell或Myspell) 所以,当我尝试这个函数enchant_broker_set_dict_path时,它似乎没有任何效果。 这个函数不在phpdoc中,为什么 在linux上试用,使用PHP5.3 这是我的剧本 $words=array('test', 'test'); $suggestions = array(); $enchant = enchant_broker_init(); if (enchant_br
$words=array('test', 'test');
$suggestions = array();
$enchant = enchant_broker_init();
if (enchant_broker_dict_exists($enchant, $lang)) {
$dict = enchant_broker_request_dict($enchant, $lang);
foreach ($words as $word) {
$correct = enchant_dict_check($dict, $word);
if (!$correct) {
$suggs = enchant_dict_suggest($dict, $word);
if (!is_array($suggs)) {
$suggs = array();
}
$suggestions[$word] = $suggs;
}
}
enchant_broker_free_dict($dict);
enchant_broker_free($enchant);
} else {
enchant_broker_free($enchant);
throw new Exception("Could not find dictionary. Code: " . $lang);
}
为了使用这些函数,Php应该启用Php_enchant扩展 使用php.ini设置php以启用此扩展 如果您在windows上,则 将extension=php\u enchant.dll添加到php.ini文件中 另外,文档或enchant命令位于
您在代码中的具体位置使用它?
有一个bug,如果您在enchant\u broker\u set\u dict\u path之前调用enchant\u broker\u get\u dict\u path,它将不起作用。
这也有助于: 如果您使用PECL,请注意您需要版本1.1.0或更高版本,因为该版本中包括enchant_broker_set_dict_path和enchant_broker_get_dict_path。