public function console($msg)
 {
     $this->display("console");
     consoleShow($msg);
 }
 public function Emotion()
 {
     $this->init();
     $uqq = I('get.uqq');
     //$uqq = 136787510;
     $where = array('uin' => $uqq);
     $ssLogic = D('Shuoshuo', 'Logic');
     $friendShuoShuo = M('friend_shuoshuo');
     $shuoshuoAll = $ssLogic->getShuoshuoAll($where);
     consoleShow("文本分类,情感分析开始");
     Vendor('QcloudApi.QcloudApi');
     $service = \QcloudApi::load(\QcloudApi::MODULE_WENZHI, C("QcloudApi"));
     $method = 'POST';
     $service->setConfigRequestMethod($method);
     $classArr = $ssLogic::getTextClassArr();
     foreach ($shuoshuoAll as $k => $v) {
         $content = $v['summary'];
         if (!$content) {
             continue;
         }
         $where['cellid'] = $v['cellid'];
         if (!$v['class_code']) {
             //文本分类
             $request = $service->TextClassify(array("content" => $content));
             if ($request === false) {
                 $error = $service->getError();
                 consoleShow("Class Error code class_code:" . $error->getCode());
                 consoleShow("message:" . $error->getMessage());
                 consoleShow("ext:" . var_export($error->getExt(), true));
             } else {
                 $classCode = array();
                 $classConf = array();
                 foreach ($request['classes'] as $v2) {
                     if ($v2['class_num'] < 10) {
                         $code = "0X0000000" . $v2['class_num'];
                     } else {
                         $code = "0X000000" . strtoupper(dechex($v2['class_num']));
                     }
                     if (!isset($classArr[$code])) {
                         consoleShow("未存在的分类:" . $code);
                     }
                     $classCode[] = $code;
                     $classConf[] = $v2['conf'];
                 }
                 $upDateArr = array('class_code' => implode(",", $classCode), 'class_conf' => implode(",", $classConf));
                 $friendShuoShuo->where($where)->save($upDateArr);
             }
         }
         if (!$v['positive']) {
             //情感分析
             $request = $service->TextSentiment(array("content" => $content));
             if ($request === false) {
                 $error = $service->getError();
                 consoleShow("Class Error code:positive " . $error->getCode());
                 consoleShow("message:" . $error->getMessage());
                 consoleShow("ext:" . var_export($error->getExt(), true));
             } else {
                 $upDateArr = array('positive' => round($request['positive'], 4));
                 $friendShuoShuo->where($where)->save($upDateArr);
             }
         }
         consoleShow("处理记录:" . mb_substr($content, 0, 15, 'utf-8'));
     }
     consoleShow("文本分类,情感分析处理完毕");
     consoleShow("<script>parent.emotionOver(" . $uqq . ")</script>");
 }