首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Php,enchant库,如何选择字典(如aspell或myspell)

Php,enchant库,如何选择字典(如aspell或myspell)
EN

Stack Overflow用户
提问于 2014-01-14 22:32:23
回答 2查看 1.1K关注 0票数 1

我在试着附魔符号库。

我有一个运行良好的脚本,但我可以在几个字典(Aspell或Myspell)之间进行选择

因此,当我尝试这个函数enchant_broker_set_dict_path时,它似乎没有任何效果。而这个函数不在phpdoc中,为什么?

用php 5.3在linux上试用过

这是我的脚本

代码语言:javascript
复制
$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);
    }
EN

回答 2

Stack Overflow用户

发布于 2014-06-09 21:35:35

Php应该启用php_enchant扩展才能使用这些函数。

使用您的php.ini设置php以启用此扩展。

如果你使用的是windows,那么在你的php.ini文件中添加extension=php_enchant.dll。

此外,文档或enchant命令位于http://www.php.net/manual/en/function.enchant-broker-init.php

票数 0
EN

Stack Overflow用户

发布于 2014-11-18 22:59:56

你在你的代码中具体在哪里使用它呢?

有一个bug,如果你在enchant_broker_set_dict_path之前调用enchant_broker_get_dict_path,它不会工作。

这也可能会有帮助:http://blog.iwanluijks.nl/?!=/post/1-using-enchant-with-php-on-windowspart-1.html

如果您使用PECL,那么请注意,您需要1.1.0或更高版本,因为该版本中包含了enchant_broker_set_dict_path和enchant_broker_get_dict_path。

http://pecl.php.net/package/enchant/1.1.0

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21116124

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档