class TokenizedMessage {
public function __construct($text, $tags = []) {
- $this->text = $text;
+ $this->text = trim($text);
$this->tags = $tags;
- $this->raw = strtolower(preg_replace('/[^\w]/u', '', $text));
- $this->tokens = array_values(array_map('trim', array_filter(preg_split('/\b/', strtolower($text)))));
+ $this->raw = strtolower(preg_replace('/[^\w]/u', '', $this->text));
+ $this->tokens = array_values(array_map('trim', array_filter(preg_split('/\b/', strtolower($this->text)))));
$this->emoteless = $this->text;
if (isset($this->tags['emotes']) && !empty($this->tags['emotes'])) {
public function classify() {
if (is_null($this->classification)) {
- if (empty($this->raw)) {
+ if (empty($this->text)) {
$this->classification = 'unclassified';
} else if ($this->startsWith('!')) {
$this->classification = 'cmd';
$this->classification = 'love';
} else if ($this->hasToken(['nani', 'wat', 'wtf']) || $this->hasEmoteThatEndsWith(['wat', 'wtf'])) {
$this->classification = 'wtf';
+ } else if ($this->hasConsecutiveTokens([':', 'eyes', ':']) || $this->hasEmoteThatEndsWith(['eyes'])) {
+ $this->classification = 'eyes';
+ } else if ($this->hasEmoteThatEndsWith(['angry', 'rage', 'ree'])) {
+ $this->classification = 'rage';
+ } else if ($this->hasToken([':(']) || $this->hasEmoteThatEndsWith(['cry', 'sad'])) {
+ $this->classification = 'sad';
+ } else if ($this->hasToken(['monkas', 'sweat_smile']) || $this->hasEmoteThatEndsWith(['sweat'])) {
+ $this->classification = 'sweat';
} else if ($this->endsWithEmoteless('?')) {
$this->classification = 'question';
} else if ($this->startsOrEndsWithRaw(['o7']) || $this->hasEmoteThatContains('salut')) {