略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: pspell_config_data_dir

2024-11-13

pspell_config_data_dir

(PHP 5, PHP 7, PHP 8)

pspell_config_data_dirLocation of language data files

说明

pspell_config_data_dir(PSpell\Config $config, string $directory): bool

警告

本函数还未编写文档,仅有参数列表。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.1.0 The config parameter expects an PSpell\Config instance now; previously, a 资源(resource) was expected.
add a noteadd a note

User Contributed Notes 1 note

up
0
alexxed at gmail dot com
14 years ago
Here's an example of how to use pspell when you don't want or you can't use the dictionaries installed on the system.
<?
$text_to_check = 'I can sspeak English';
// optional. clean text a bit
$clean_text_to_check = preg_replace('/[^a-z0-9\-\.!;]+/i', ' ', $text_to_check);
// get a word list
$word_list = preg_split('/\s+/', $clean_text_to_check);

$pspell_config = pspell_config_create("en", null, null, 'utf-8');

// if the aspell dictionaries that you want are not installed,
// copy the aspell dictionaries and set the path to the dictionaries here
pspell_config_data_dir($pspell_config, "/home/alex/dictionaries/");
pspell_config_dict_dir($pspell_config, "/home/alex/dictionaries/");
$pspell_link = pspell_new_config($pspell_config);

foreach($word_list as $word) {

    if (!pspell_check($pspell_link, trim($word))) {
        $suggestions = pspell_suggest($pspell_link, trim($word));

        echo $word . ' misspelled <br />';
        foreach ($suggestions as $suggestion) {
            echo "\t Possible spelling: $suggestion <br />";
        }
    }
    else {
        // correct spelling
    }
}
?>

官方地址:https://www.php.net/manual/en/function.pspell-config-data-dir.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3