Пример #1
0
 protected function _get_stemmed_text($text)
 {
     $result = '';
     $text = strip_tags($text);
     $stop_words = Model_Search_Stopwords::get();
     // Parse original text and stem all words that are not tags
     $tkn = new Model_Search_Tokenizer();
     $tkn->set_text($text);
     $tkn->stopwords = $stop_words;
     $stemmer = new Model_Search_Stemmer($tkn);
     while ($cur = $tkn->next()) {
         $result .= $stemmer->stem($cur);
     }
     return $result;
 }
Пример #2
0
 /**
  * 
  * @param string $keyword
  * @return string
  */
 public function stem_query($keyword)
 {
     $result = '';
     $text = UTF8::strtolower($keyword);
     $text = trim($text);
     $text = strip_tags($text);
     $stop_words = Model_Search_Stopwords::get();
     // Parse original text and stem all words that are not tags
     $tkn = new Model_Search_Tokenizer();
     $tkn->set_text($text);
     $tkn->stopwords = $stop_words;
     $stemmer = new Model_Search_Stemmer($tkn);
     while ($cur = $tkn->next()) {
         $result .= $stemmer->stem($cur);
     }
     return $result;
 }
Пример #3
0
 /**
  * @return Model_Search_Tokenizer
  */
 public static function instance()
 {
     if (!isset(self::$instances)) {
         self::$instances = new self();
     }
     return self::$instances;
 }