簡體   English   中英

拼音不起作用

[英]Pspell don't work

請幫我解決pspell問題。 我已經安裝了 aspell,並在終端中完成了以下命令:

sudo apt-get install libpspell-dev 
sudo apt-get install php7.0-pspell
sudo apt-get install aspell-en

我的操作系統是 linux Mint 17。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);
    }
}

我只嘗試過 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);
}

確保一個字一個字地給它你的短語,它不能處理句子或不尋常的序列。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM