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; }
/** * * @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; }
/** * @return Model_Search_Tokenizer */ public static function instance() { if (!isset(self::$instances)) { self::$instances = new self(); } return self::$instances; }