/**
  * 简单搜索测试
  * @return void
  */
 public function testSearch()
 {
     $this->info("\n\r........................start search............................\n\r");
     $bank = new Bank();
     $words = ['进口', '中式', 'zs', 'zhong', 'm', 'ji', '窗框', 'ck', 'pvc', 's', 'EVO', 'samsung'];
     $specialTakeCare = ['进口', '进k', '进ko', '进kou', 'j口', 'ji口', 'jin口', 'j', 'jk', 'jik', 'jink', 'jink', 'jinko', 'jinkou'];
     $insertWords = ['软包', 'rb', 'ru', 'rua', 'ruan', 'ruanb', 'ruanba', 'ruanbao'];
     $words = array_merge($words, $specialTakeCare, $insertWords);
     foreach ($words as $word) {
         $results = $bank->withdrawal($word);
         $this->comment("\n\r" . 'result..' . $word);
         foreach ($results as $result) {
             $this->info('   ' . $word . '=>' . $result);
         }
     }
     $this->info("........................  system search............................\n\r");
     $suggest = new Suggest();
     foreach ($words as $word) {
         $results = $suggest->search($word);
         $this->comment("\n\r" . 'result..' . $word);
         foreach ($results as $result) {
             $this->info('   ' . $word . '=>' . $result);
         }
     }
     $this->assertTrue(true);
     $this->info("........................  end search............................\n\r");
 }
示例#2
0
 /**
  * @param array $dict
  */
 public function createIndex($dict = [])
 {
     // TODO 创建索引
     $bank = new Bank();
     $sentences = $dict;
     foreach ($sentences as $sentence) {
         $bank->deposit(new Coin($sentence));
     }
 }
示例#3
0
 /**
  * 测试创建索引
  *
  * @return null
  */
 public function testIndex()
 {
     // TODO 测试拼音 的 储存
     // TODO 拼音的读取
     // TODO 更多的插件
     $this->comment('start index...');
     $bank = new Bank();
     $bank->robAll();
     $sentences = self::getData();
     foreach ($sentences as $sentence) {
         $bank->deposit(new Coin($sentence));
     }
     $this->assertTrue(true);
     return null;
 }
示例#4
0
 /**
  * 清空数据库
  *
  * @return mixed|void
  */
 public function clear()
 {
     return $this->bank->robAll();
 }