コード例 #1
0
ファイル: Article.php プロジェクト: REZ1DENT3/mystem
 /**
  * @param string $text
  */
 public function __construct($text)
 {
     $offset = 0;
     $this->article = $text;
     $stemmed = Mystem::stemm($text);
     foreach ($stemmed as $part) {
         $word = ArticleWord::newFromLexicalString($part, 1, $this->article);
         $position = @mb_strpos($this->article, $word->original, $offset);
         if ($position === false) {
             //Can't find original word
             $position = $offset + 1;
         }
         $word->position = $position;
         $offset = $word->position + mb_strlen($word->original);
         $this->words[] = $word;
     }
 }
コード例 #2
0
ファイル: Word.php プロジェクト: REZ1DENT3/mystem
 /**
  * @param string $word
  * @param int $maxVariants
  * @return Word
  */
 public static function stemm($word, $maxVariants = null)
 {
     $lexicalString = Mystem::stemm($word);
     return self::newFromLexicalString(isset($lexicalString[0]) ? $lexicalString[0] : $word, $maxVariants);
 }