$this->text = mb_substr($text, mb_strlen($tags['reply-parent-display-name']) + 2);
}
$this->raw = strtolower(preg_replace('/[^\w]/u', '', $this->text));
- $this->tokens = array_values(array_map('trim', array_filter(preg_split('/\b/u', strtolower($this->text)))));
+ $this->tokens = array_values(array_filter(array_map('trim', array_filter(preg_split('/\b/u', strtolower($this->text))))));
$this->emoteless = $text;
if (isset($this->tags['emotes']) && !empty($this->tags['emotes'])) {
$this->emoteless = trim(preg_replace('/\s+/u', ' ', $this->emoteless));
}
$this->emoteless_raw = strtolower(preg_replace('/[^\w]/u', '', $this->emoteless));
- $this->emoteless_tokens = array_values(array_map('trim', array_filter(preg_split('/\b/u', strtolower($this->emoteless)))));
+ $this->emoteless_tokens = array_values(array_filter(array_map('trim', array_filter(preg_split('/\b/u', strtolower($this->emoteless))))));
}
public static function fromIRC(IRCMessage $msg) {
$this->assertTrue(TokenizedMessage::fromString('Willkommen auf Starbase 47')->isSpammy());
}
+ public function test_tokenizer() {
+ $this->assertTrue(TokenizedMessage::fromString('@HorstieBot wie viele warps?')->hasConsecutiveTokens(['wie', 'viele']));
+ $this->assertFalse(TokenizedMessage::fromString('@HorstieBot wie viele warps?')->hasConsecutiveTokens(['wo', 'wurst']));
+ }
}