Exemplo n.º 1
0
 public function get_words($text)
 {
     $detect = $this->getClassifier();
     $stopwords = $this->getStopwords();
     $lang = 'french';
     if (!is_string($lang)) {
         throw new \RuntimeException("Cannot detect the language of the text");
     }
     if (empty($stopwords[$lang])) {
         throw new \RuntimeException("We dont have an stop word for {$lang}, please add it in " . __DIR__ . "/Stopword/{$lang}-stopwords.txt and run generate.php");
     }
     $this->stopword = $stopwords[$lang];
     $this->common_words = [];
     $common_words = $this->normalize_keywords(file(__DIR__ . '/Stopword/common-french.txt', FILE_IGNORE_NEW_LINES));
     foreach ($common_words as $cw) {
         $this->common_words[$cw] = 1;
     }
     $this->lang = $lang;
     return parent::get_words($text);
 }
Exemplo n.º 2
0
 public function get_words($text)
 {
     $detect = $this->getClassifier();
     $stopwords = $this->getStopwords();
     $lang = $detect->detect($text);
     if (!is_string($lang)) {
         throw new \RuntimeException("Cannot detect the language of the text");
     }
     if (empty($stopwords[$lang])) {
         throw new \RuntimeException("We dont have an stop word for {$lang}, please add it in " . __DIR__ . "/Stopword/{$lang}-stopwords.txt and run generate.php");
     }
     $this->stopword = $stopwords[$lang];
     $this->lang = $lang;
     return parent::get_words($text);
 }