Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Pspell Functions : pspell_config_data_dir

pspell_config_data_dir

location of language data files (PHP 5)
bool pspell_config_data_dir ( int conf, string directory )

Warning:

This function is currently not documented; only the argument list is available.

Return Values

Returns TRUE on success or FALSE on failure.

Code Examples / Notes » pspell_config_data_dir

alexxed

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
   }
}
?>


Change Language


Follow Navioo On Twitter
pspell_add_to_personal
pspell_add_to_session
pspell_check
pspell_clear_session
pspell_config_create
pspell_config_data_dir
pspell_config_dict_dir
pspell_config_ignore
pspell_config_mode
pspell_config_personal
pspell_config_repl
pspell_config_runtogether
pspell_config_save_repl
pspell_new_config
pspell_new_personal
pspell_new
pspell_save_wordlist
pspell_store_replacement
pspell_suggest
eXTReMe Tracker