nlp_feedback.h
Go to the documentation of this file.
1 
7 #ifndef RESULT_FEEDVACK_HPP
8 #define RESULT_FEEDVACK_HPP
9 #include <curl/curl.h>
10 #include <fstream>
11 #include <iostream>
12 #include <vector>
13 
16 {
17  NO_ACTION = 0,
35 };
36 
39 {
45 
46 };
47 
50 {
51 public:
53  {
54  }
55 
62  bool resultIsValid(const std::string recog_result);
63 
70  std::vector<std::vector<std::string>> readAnswerTable(std::string answer_config_file);
71 
78  bool keywordDetection();
79 
85  void keywordResponse(const std::string log_path);
86 
92  std::vector<std::string> answerContent();
93 
99  int actionDetect();
100 
106  bool isKeywordRepeated(std::string key_word);
107 
112  void uninitNLP();
113 
114 private:
115  std::vector<std::string> answer_dictionary_; // 存储一个关键词及其对应的反馈内容
116  std::vector<std::vector<std::string>> answer_table_; // 存储整个csv表格的内容
117  int detect_count_ = 0; // 存储识别到的关键词存在的回复的个数
118  std::string recog_final_result_; // 从json串中解析出的语音识别结果
119  std::string base_path_;
120  std::string tts_path_;
121  void robotPlay();
122  int robotAction();
123 };
124 
127 {
128 public:
134  void setAskJson(const std::string ask_str);
135 
141  std::string callTulingApi();
142 
148  std::string textFromJson();
149 
154  void uninitTuling();
155 
156 private:
157  std::string tuling_url_ = "http://openapi.tuling123.com/openapi/api/v2";
158  std::string tuling_key_ = "58dcf416803a401a8b0770b9c551acef";
159  std::string ask_json_;
160  std::string answer_json_;
161  std::string answer_text_;
162  static size_t http_data_writer(void* data, size_t size, size_t nmemb, void* content);
163 };
164 
165 #endif
std::string tts_path_
Definition: nlp_feedback.h:120
int actionDetect()
监测是否需要机器人控制以及控制类型..
std::vector< std::string > answerContent()
返回一个反馈内容(包含语音和动作的反馈).
std::string answer_text_
Definition: nlp_feedback.h:161
bool resultIsValid(const std::string recog_result)
判断语音识别结果是否为有效结果,若语音识别模块传来的结果!=none_result,则为有效.
std::string log_path
std::vector< std::string > answer_dictionary_
Definition: nlp_feedback.h:115
std::string ask_json_
Definition: nlp_feedback.h:159
std::string base_path_
Definition: nlp_feedback.h:119
void keywordResponse(const std::string log_path)
根据响应vector内的值调用不同的响应接口,如发布控制指令,播放音频文件等.
void uninitNLP()
一次处理结束后释放资源.
std::string recog_final_result_
Definition: nlp_feedback.h:118
bool isKeywordRepeated(std::string key_word)
判断新加的关键词是否已被定义过.
std::string answer_json_
Definition: nlp_feedback.h:160
RobotAciton
Definition: nlp_feedback.h:15
ActionMode
Definition: nlp_feedback.h:38
bool keywordDetection()
根据交互模式answer_table_判断识别出的关键词是否有对应的响应策略. 若该关键词有对应的响应回复,存入响应向量answer_dictionary_(4).
std::vector< std::vector< std::string > > readAnswerTable(std::string answer_config_file)
读取离线对话库:defaultconfig/answer_dic.csv文件里的内容,存入answer_table_.
std::vector< std::vector< std::string > > answer_table_
Definition: nlp_feedback.h:116


xbot_talker
Author(s): wangxiaoyun
autogenerated on Sat Oct 10 2020 03:27:53