|
|
|
@ -37,18 +37,21 @@ class rcube_spellchecker_pspell extends rcube_spellchecker_engine
|
|
|
|
|
function languages()
|
|
|
|
|
{
|
|
|
|
|
$defaults = array('en');
|
|
|
|
|
$langs = array();
|
|
|
|
|
$langs = array();
|
|
|
|
|
|
|
|
|
|
// get aspell dictionaries
|
|
|
|
|
exec('aspell dump dicts', $dicts);
|
|
|
|
|
if (!empty($dicts)) {
|
|
|
|
|
$seen = array();
|
|
|
|
|
foreach ($dicts as $lang) {
|
|
|
|
|
$lang = preg_replace('/-.*$/', '', $lang);
|
|
|
|
|
$lang = preg_replace('/-.*$/', '', $lang);
|
|
|
|
|
$langc = strlen($lang) == 2 ? $lang.'_'.strtoupper($lang) : $lang;
|
|
|
|
|
if (!$seen[$langc]++)
|
|
|
|
|
|
|
|
|
|
if (!$seen[$langc]++) {
|
|
|
|
|
$langs[] = $lang;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$langs = array_unique($langs);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@ -93,8 +96,8 @@ class rcube_spellchecker_pspell extends rcube_spellchecker_engine
|
|
|
|
|
// tokenize
|
|
|
|
|
$text = preg_split($this->separator, $text, NULL, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
|
|
|
|
|
|
|
|
|
|
$diff = 0;
|
|
|
|
|
$matches = array();
|
|
|
|
|
$diff = 0;
|
|
|
|
|
$matches = array();
|
|
|
|
|
|
|
|
|
|
foreach ($text as $w) {
|
|
|
|
|
$word = trim($w[0]);
|
|
|
|
@ -136,8 +139,9 @@ class rcube_spellchecker_pspell extends rcube_spellchecker_engine
|
|
|
|
|
|
|
|
|
|
$suggestions = pspell_suggest($this->plink, $word);
|
|
|
|
|
|
|
|
|
|
if (count($suggestions) > self::MAX_SUGGESTIONS)
|
|
|
|
|
if (count($suggestions) > self::MAX_SUGGESTIONS) {
|
|
|
|
|
$suggestions = array_slice($suggestions, 0, self::MAX_SUGGESTIONS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return is_array($suggestions) ? $suggestions : array();
|
|
|
|
|
}
|
|
|
|
|