From fc1617481d974748df00a519984ec184d8741d2d Mon Sep 17 00:00:00 2001 From: ekinhbayar Date: Sat, 3 Dec 2016 16:27:21 +0200 Subject: [PATCH] Fix undefined case --- src/BrillTagger.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/BrillTagger.php b/src/BrillTagger.php index 0b815d0..6390a54 100644 --- a/src/BrillTagger.php +++ b/src/BrillTagger.php @@ -35,9 +35,9 @@ public function tag($text) { } # get from dictionary if set - if ($this->tokenExists($token)) { - $tags[$i]['tag'] = $this->dictionary[strtolower($token)][0]; - } + $tags[$i]['tag'] = $this->tokenExists($token) + ? $this->dictionary[strtolower($token)][0] + : 'NN'; $tags[$i]['tag'] = $this->transformNumerics($tags[$i]['tag'], $token); @@ -190,7 +190,9 @@ public function isPossessivePronoun($tag) { * @return bool */ public function isAdjective($token) { - return (substr($token, -2) == 'al' || in_array('JJ', $this->dictionary[strtolower($token)])); + return ($this->tokenExists($token)) + ? in_array('JJ', $this->dictionary[strtolower($token)]) + : substr($token, -2) == 'al'; } /**