查看: 811|回复: 2
|
PSPELL 功能[RESOLVED]
[复制链接]
|
|
楼主 |
发表于 3-10-2006 12:04 AM
|
显示全部楼层
hi everyone,
Its' me again. After browsing through GNU Aspell i found that actually the Aspell actually needs a dictionary word list which is include in the GNU aspell folder shared public.. After I try to install the Aspell (DOS application works fine, but the PHP file has problem, which is:
Warning: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language "en".
my spelling checking class is something like (copy from zend.com):
class spell_checker {
var $personal_path = "c:\Aspell\dict";
var $skip_len = 3;
var $mode = PSPELL_NORMAL;
var $pspell_handle;
var $pspell_cfg_handle;
var $personal = false;
function spell_checker($dict = "en", $pconfig = "") {
$pspell_cfg_handle = pspell_config_create($dict);
pspell_config_ignore($pspell_cfg_handle,$skip_len);
pspell_config_mode($pspell_cfg_handle, $mode);
if($pconfig != "") {
$pspell_handle = pspell_config_personal($pspell_cfg_handle, $personal_path.$pconfig.".rws");
$personal = true;
}
$pspell_handle = pspell_new_config($pspell_cfg_handle);
echo $pspell_handle;
}
function check($word) {
return pspell_check($this->pspell_handle, $word);
}
function suggest($word) {
return pspell_suggest($this->pspell_handle, $word);
}
function add($word) {
if(!$personal) return false;
return pspell_add_to_personal($this->pspell_handle, $word);
}
function close() {
if(!$personal) return;
return pspell_save_wordlist($this->pspell_handle);
}
};
and i try it using (copy from zend.com):
require_once("function.php");
$spell_chk = new spell_checker("en", "zend_john");
$spell_chk->add('ttest');
$mystr = "This is a ttest of a mispellled word";
$words = split("[^[:alpha:]']+", $mystr);
foreach($words as $val) {
if($spell_chk->check($val)) {
echo "The word '$val' is spelled correctly<BR>";
} else {
echo "The word '$val' was not spelled correctly<BR>";
echo "Possible correct spellings are: ";
foreach($spell_chk->suggest($val) as $suggestion) {
echo ' '.$suggestion;
}
echo "<BR>";
}
}
$spell_chk->close();
Then all the error has come out, any high hand can help me???
Thanks for reading.. |
|
|
|
|
|
|
|
楼主 |
发表于 3-10-2006 12:15 AM
|
显示全部楼层
hi everyone,
Its' me again. After browsing through GNU Aspell i found that actually the Aspell actually needs a dictionary word list which is include in the GNU aspell folder shared public.. After I try to install the Aspell (DOS application works fine, but the PHP file has problem, which is:
Warning: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language "en".
my spelling checking class is something like (copy from zend.com):
class spell_checker {
var $personal_path = "c:\Aspell\dict";
var $skip_len = 3;
var $mode = PSPELL_NORMAL;
var $pspell_handle;
var $pspell_cfg_handle;
var $personal = false;
function spell_checker($dict = "en", $pconfig = "") {
$pspell_cfg_handle = pspell_config_create($dict);
pspell_config_ignore($pspell_cfg_handle,$skip_len);
pspell_config_mode($pspell_cfg_handle, $mode);
if($pconfig != "") {
$pspell_handle = pspell_config_personal($pspell_cfg_handle, $personal_path.$pconfig.".rws");
$personal = true;
}
$pspell_handle = pspell_new_config($pspell_cfg_handle);
echo $pspell_handle;
}
function check($word) {
return pspell_check($this->pspell_handle, $word);
}
function suggest($word) {
return pspell_suggest($this->pspell_handle, $word);
}
function add($word) {
if(!$personal) return false;
return pspell_add_to_personal($this->pspell_handle, $word);
}
function close() {
if(!$personal) return;
return pspell_save_wordlist($this->pspell_handle);
}
};
and i try it using (copy from zend.com):
require_once("function.php");
$spell_chk = new spell_checker("en", "zend_john");
$spell_chk->add('ttest');
$mystr = "This is a ttest of a mispellled word";
$words = split("[^[:alpha:]']+", $mystr);
foreach($words as $val) {
if($spell_chk->check($val)) {
echo "The word '$val' is spelled correctly<BR>";
} else {
echo "The word '$val' was not spelled correctly<BR>";
echo "Possible correct spellings are: ";
foreach($spell_chk->suggest($val) as $suggestion) {
echo ' '.$suggestion;
}
echo "<BR>";
}
}
$spell_chk->close();
Then all the error has come out, any high hand can help me???
Thanks for reading.. |
|
|
|
|
|
|
| |
本周最热论坛帖子
|