0

我尝试使用以下命令在 Ubuntu 可信赖发行版上安装 pspell:

sudo apt-get install libpspell-dev sudo apt-get install php5-pspell sudo apt-get install aspell-he

该过程似乎已成功,因为在安装过程中没有返回错误。

但是,当我在实际操作中尝试此操作时,我得到了一系列问号(�):

pspell_config_create("he");
$t = pspell_new('he');

$suggestions = pspell_suggest($t, 'דבל');


return view('master', compact('suggestions')); 
// the above line can be swapped with"
// print_r($suggestions);
// and the result stays the same

我使用视图的原因是因为我认为网页可能需要设置一些字符集,所以我使用 HTML5 文档结构来实现这一点,但结果保持不变。

我的 HTML 标记:

<!doctype html>
<html lang="he">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    סתם טקסט לבדיקה
    <?php print_r($suggestions); ?>
</body>
</html>

从中返回的结果:

סתם טקסט לבדיקה Array ( [0] => � [1] => � [2] => � [3] => � [4] => � [5] => � [6] => � )

我还尝试过另一个测试:

return pspell_check($t, 'הגדא') ? 'there is' : 'nope';

并且由于某种原因,对于任何给定的单词,它都以“nope”返回,这意味着pspell_check返回false

知道如何解决这个问题吗?

编辑:

尝试检索结果的长度时:

<!doctype html>
<html lang="he">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
@foreach($suggestions as $suggestion)
    {{ strlen($suggestion) }} <br>
@endforeach
</body>
</html>

结果是:

1 
1 
1 
1 
1 
1 
1 

这意味着pspell_suggest方法返回的结果可能在从 aspell 字典中检索数据时出现问题?

4

2 回答 2

0
于 2015-06-21T16:59:50.533 回答
0

Since every word check returned with the same results it got me suspected that maybe the value that is being passed to the pspell_suggest function is corrupted.

What I did was simply tell pspell to use UTF-8:

$t = pspell_new('he', "", "", "utf-8");

This solved the problem.

于 2015-06-21T17:27:15.947 回答