拜托,帮我解决拼字问题。我安装了一个咒语,并在终端中完成了以下操作:
sudo apt-get install libpspell-dev
sudo apt-get install php7.0-pspell
sudo apt-get install aspell-en我的操作系统是LinuxMint17.PHP-7.0.28。当我尝试使用函数检查器时,它会返回空数组。但我清楚地知道,它在托管方面是正确的。职能守则:
function fixMistakeInQString($string, $lang){
$pspell_config = pspell_config_create($lang);
pspell_config_mode($pspell_config, PSPELL_FAST);
$pspell_link = pspell_new_config($pspell_config);
if (!pspell_check($pspell_link, $string)) {
$result = pspell_suggest($pspell_link, $string);
foreach ($result as $key => $value){
if(preg_match('~\s~ui', $value) || preg_match('~-~ui', $value)){
unset($result[$key]);
}
}
return $result;
}else{
return array($string);
}
}发布于 2022-06-29 08:10:34
我只试过使用PHP8.1,但就像这样,它在我的系统上运行得很顺利。安装依赖项(例如Ubuntu):
sudo apt install aspell
sudo apt install php8.1-pspell
sudo apt install aspell-en或者高山:
apk add aspell aspell-en php81-pspell然后可以在PHP中运行:
<?php
$pspell = \pspell_new("en", null, null, "utf-8", PSPELL_FAST);
if (!\pspell_check($pspell, $word)) {
$suggesstion = \pspell_suggest($pspell, $word);
}一定要逐字逐句地给出你的短语,它不能处理句子或不寻常的序列。
https://stackoverflow.com/questions/49515525
复制相似问题