Esempio n. 1
0
 /**
  * Dokonuje korekty ortograficznej.
  * Je¶li wyraz jest w s³owniku, przepisuje go.
  * W przeciwnym razie próbuje dodaæ znaki diakrytyczne (dodaje wszystkie
  * znalezione wersje).
  * Je¶li i to zawiedzie poszukuje w s³owniku ortograficznym pierwszych piêciu
  * wyrazów przypominaj±cych szukany i dodaje je do listy wyrazów.
  * Gdy nic nie zostanie odnalezione i aktywy jest parametr $copy_unk
  * wyraz w oryginalnej postaci jest przenoszony do listy.
  *
  * @param array $comment Tablica wyrazów do przeanalizowania.
  * @param bool $copy_unk Czy kopiowaæ nieznane wyrazy?
  * @return array Tablica wyrazów lub false, je¶li nie ma wyrazów.
  */
 protected function checkSpelling(array $comment, $copy_unk = false)
 {
     $tok_comment = array();
     foreach ($comment as $w) {
         if (pspell_check(self::$pspell, $w)) {
             $tok_comment[] = $w;
         } elseif ($temp = self::$fsaa->accent_word($w)) {
             $tok_comment = array_merge($tok_comment, $temp);
         } elseif (strlen($w) > 3 && count($temp = pspell_suggest(self::$pspell, $w)) > 0) {
             $tok_comment = array_merge($tok_comment, array_slice(array_filter($temp, array($this, "pspell_filter")), 0, 5));
         } else {
             if ($copy_unk) {
                 $tok_comment[] = $w;
             }
         }
     }
     if (count($tok_comment) == 0) {
         return false;
     }
     return $tok_comment;
 }
Esempio n. 2
0
 /*  foreach ($tok_comment1 as $w) {
     if (pspell_check($pspell_link, $w)) {
       $tok_comment[] = $w;
     } elseif (($temp = $fsaa->accent_word($w))) {
       $tok_comment = array_merge($tok_comment, $temp);
     } elseif (strlen($w)>3 && count($temp = pspell_suggest($pspell_link,$w))>0) {
       $tok_comment = array_merge($tok_comment, array_slice(array_filter($temp,"pspell_filter"),0,5));
     } else {
       //$tok_comment[] = $w;
     }
   }
   $stoper->set('accents&spell');*/
 foreach ($tok_comment1 as $w) {
     if ($fsas->find_word($w)) {
         $tok_comment[] = $w;
     } elseif ($temp = $fsaa->accent_word($w)) {
         $tok_comment = array_merge($tok_comment, $temp);
     } elseif (strlen($w) > 3 && ($temp = $fsas->spell_word($w))) {
         $tok_comment = array_merge($tok_comment, array_slice($temp, 0, 5));
         // $tokenizer->checkOnStoplist($temp));
     } else {
         //$tok_comment[] = $w;
     }
 }
 unset($tok_comment1);
 $stoper->set('accents&spell');
 // lematyzacja
 $tok_comment1 = array();
 if (count($tok_comment) > 0) {
     foreach ($tok_comment as $w) {
         $temp = $fsal->lematize($w);