Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3.0327 |
Changes | 0 |
1 | <?php |
||
18 | 4 | public function __construct($text) |
|
19 | { |
||
20 | 4 | $offset = 0; |
|
21 | 4 | $this->article = $text; |
|
22 | |||
23 | 4 | $stemmed = Mystem::stemm($text); |
|
24 | 4 | foreach ($stemmed as $part) { |
|
25 | 4 | $word = ArticleWord::newFromLexicalString($part, 1, $this->article); |
|
26 | 4 | $position = @mb_strpos($this->article, $word->original, $offset); |
|
27 | 4 | if ($position === false) { //Can't find original word |
|
28 | $position = $offset + 1; |
||
29 | } |
||
30 | 4 | $word->position = $position; |
|
31 | 4 | $offset = $word->position + mb_strlen($word->original); |
|
32 | 4 | $this->words[] = $word; |
|
33 | 4 | } |
|
62 |