public function testPrefixesForPhrase() { $min = 2; $swords = ['the']; $this->assertEquals(['kn', 'kni', 'knic', 'knick', 'knicks'], Str::prefixesForPhrase('the knicks', $min, $swords)); $this->assertEquals(['te', 'tes', 'test', 'testi', 'testin', 'th', 'thi', 'this'], Str::prefixesForPhrase("testin' this", $min, $swords)); $this->assertEquals(['te', 'tes', 'test', 'testi', 'testin', 'th', 'thi', 'this'], Str::prefixesForPhrase("testin' this", $min, $swords)); $this->assertEquals(['te', 'tes', 'test'], Str::prefixesForPhrase('test test', $min, $swords)); $this->assertEquals(['so', 'sou', 'soul', 'soulm', 'soulma', 'soulmat', 'soulmate'], Str::prefixesForPhrase('SoUlmATE', $min, $swords)); $this->assertEquals(['测试', '测试中', '测试中文', 'te', 'tes', 'test'], Str::prefixesForPhrase('测试中文 test', $min, $swords)); $min = 4; $this->assertEquals(['同华东生', '同华东生产', '同华东生产队', 'abcd', 'abcde'], Str::prefixesForPhrase('同华东生产队 abcde', $min, $swords)); }
/** * Computes all the word prefixes for a given item which satisfy the * min-complete requirement and are not in the stop-words array. * * @param array $item * @return array */ protected function prefixes($item) { return Str::prefixesForPhrase($this->itemPhrase($item), $this->getMinComplete(), $this->getStopWords()); }