Exemplo n.º 1
0
 /**
  * 关键词分词
  *
  * @Author tianyunzi
  * @DateTime 2015-10-16T10:38:46+0800
  *
  * @param [type] $keyword
  *            [description]
  * @return array [description]
  */
 public function splitKeywordHelper($keyword)
 {
     if (empty($keyword)) {
         return array();
     }
     $url = $this->di['config']->base->split . "/wd/" . urlencode($keyword);
     $num = 3;
     while ($num) {
         $res = Tools::curl($url, '', '', true, 5);
         if ($res[0] == 200) {
             $res[1] = str_replace("+", "", $res[1]);
             $keywords = explode(" ", $res[1]);
             $keywords = array_filter($keywords);
             return $keywords;
         }
         $num--;
     }
     return array($keyword);
 }