List Info

Thread: note 78492 added to function.pspell-config-data-dir




note 78492 added to function.pspell-config-data-dir
user name
2007-10-15 02:21:49
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
    }
}
?>
----
Server IP: 193.226.19.85
Probable Submitter: 89.136.33.78
----
Manual Page -- http://www.php.net/manual/en/function.pspell-con
fig-data-dir.php
Edit        -- https://master
.php.net/note/edit/78492
Del: integrated  -- h
ttps://master.php.net/note/delete/78492/integrated
Del: useless     -- http
s://master.php.net/note/delete/78492/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/78492/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/78492/spam
Del: non-english -- 
https://master.php.net/note/delete/78492/non-english
Del: in docs     -- http
s://master.php.net/note/delete/78492/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78492
Reject      -- https://mast
er.php.net/note/reject/78492
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )