From ece71f76030f2c055214ec496a21e123388fa63f Mon Sep 17 00:00:00 2001 From: vanry Date: Wed, 1 Aug 2018 20:20:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20scws=20=E5=88=86=E8=AF=8D?= =?UTF-8?q?=E4=B8=8D=E5=AE=8C=E6=95=B4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Tokenizers/ScwsTokenizer.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Tokenizers/ScwsTokenizer.php b/src/Tokenizers/ScwsTokenizer.php index 07e8822..a15ecfc 100644 --- a/src/Tokenizers/ScwsTokenizer.php +++ b/src/Tokenizers/ScwsTokenizer.php @@ -17,9 +17,13 @@ public function getTokens($text) { $this->scws->sendText($text); - $result = $this->scws->getResult(); + $tokens = []; - return $result === false ? [] : array_column($result, 'word'); + while ($result = $this->scws->getResult()) { + $tokens = array_merge($tokens, array_column($result, 'word')); + } + + return $tokens; } public function getScws()