示例#1
0
 public function _segment($text)
 {
     require_once BASEPATH . '../com_party/libraries/Segment.php';
     $text = strip_tags($text);
     if (empty($text)) {
         throw new SegmentException('正文内容不能为空');
     }
     $path = APPPATH . '../data/dict';
     try {
         $segment = new Segment($path);
         $keywords = array_values(array_unique($segment->cut($text)));
     } catch (SegmentException $e) {
         throw $e;
     }
     return $keywords;
 }