Beispiel #1
0
 public function withdrawal($word)
 {
     $parseWord = Analyze::parse($word);
     $accounts = $this->store->find($parseWord);
     $words = Analyze::sort($word, $accounts);
     return $words;
 }
Beispiel #2
0
 /**
  * 生成搜索key
  *
  * @return string
  */
 public function getSearchKey($keyChain = [Suggest::KEY_RAW, Suggest::KEY_PINYIN])
 {
     $keys = [];
     // check have pinyin word
     if (Suggest::$config['cn_inlcude_pinyin'] != true) {
         $keyChain = [Suggest::KEY_RAW];
     }
     // generate keys for search
     foreach ($keyChain as $key) {
         if ($key == Suggest::KEY_RAW) {
             // raw char
             $word = Analyze::clear($this->word);
             $keys[] = strlen($this->word) > 1 ? RedisStore::PREFIX . $this->getType() . '#' . '*' . '@' . '*' . $word . '*' : RedisStore::PREFIX . $this->getType() . '#' . '*' . '@' . $word . '*';
         }
         if ($key == Suggest::KEY_PINYIN) {
             // pinyin
             $pinyin = Analyze::clear(Pinyin::getPinyin($this->word));
             $keys[] = strlen($this->word) > 1 ? RedisStore::PREFIX . $this->getType() . '#' . '*' . $pinyin . '*' . '@' . '*' : RedisStore::PREFIX . $this->getType() . '#' . $pinyin . '*' . '@' . '*';
         }
     }
     return $keys;
 }
Beispiel #3
0
 /**
  * 查找匹配内容
  *
  * @param $word
  * @return array
  */
 public function withdrawal($word, $type)
 {
     $accounts = $this->store->find(Cheque::parse($word, $type));
     $words = Analyze::sort($word, $accounts);
     return array_slice($words, 0, 10);
 }