Commit c1044d41 by 赵国君

去某个地方别名修正

parent 5c9c8d36
......@@ -199,38 +199,28 @@ public class FormsPoster {
pairList.add(new BasicNameValuePair("query_text", curInfoPoint.get("query_text")));
pairList.add(new BasicNameValuePair("qa_threshold", threshold));
//设置初始值
historyInfoPoint.put("common_answer", "");
historyInfoPoint.put("qa_score", "0");
historyInfoPoint.put("qa_status", "OK");
logWriter.record("提交表单的数据:<br>" + pairList.toString(), 2);
JSONObject jobj = SimpleUtil.postFORM(URL, pairList);
logWriter.record("提交表单接收到的数据:<br>" + jobj.toJSONString(), 2);
String text,score, site = historyInfoPoint.get("site"), npc;
System.out.println(jobj.toJSONString());
if((Integer)jobj.get("post_status") == 1){
if(jobj.getJSONArray("qa_candidates") != null && jobj.get("qa_status").equals("OK")) {
List<JSONArray> candidates = JSON.toJavaObject(jobj.getJSONArray("qa_candidates"), List.class);
try {
for (JSONArray pair : candidates) {
List textscore = JSON.toJavaObject(pair, List.class);
Pattern findTalker = Pattern.compile(TALKER);
if ((Integer) textscore.get(1) > 95) {
Matcher m = findTalker.matcher((String) textscore.get(0));
if (m.find()) {
npc = m.group(1);
if ((GameBotUtil.sameLocation((String) textscore.get(0), curInfoPoint, historyInfoPoint, gameEnv, historyInfoPoint.get("site"), logWriter) == 1)) {
historyInfoPoint.put("common_answer", (String) textscore.get(0));
historyInfoPoint.put("qa_score", String.valueOf(textscore.get(1)));
......
......@@ -45,45 +45,10 @@ public class GetAnswerServlet extends HttpServlet {
tmpStr = entry.getValue()[0];
if(tmpStr == null || tmpStr.trim().equals(""))
continue;
tmpStr = tmpStr.replace("qiwu", "我");
receiveParamters.put(entry.getKey(), tmpStr);
}
}
String botName = receiveParamters.get("bot_name");
EngineUtils engineDBConn = null;
String gameName = null, playerName = null;
try {
engineDBConn = new EngineUtils();
gameName = engineDBConn.queryBotNickNameByName(botName);
engineDBConn = new EngineUtils();
playerName = engineDBConn.queryPlayerNickNameByName(botName);
} catch (SQLException e1) {
e1.printStackTrace();
} finally {
engineDBConn.destroy();
}
System.out.println("project name: " + gameName + " player name: " + playerName);
if(gameName == null || playerName == null || playerName.equals("") || gameName.equals("")) {
} else {
Set<Entry<String, String>> entrySet2 = receiveParamters.entrySet();
String _key = null, _value = null;
Boolean _replace = false;
for(Entry<String, String> entry : entrySet2) {
_replace = false;
_key = entry.getKey();
_value = entry.getValue();
if(_value.indexOf(gameName) != -1) {
_replace = true;
_value = _value.replace(gameName, "你");
}
if(_value.indexOf(playerName) != -1) {
_replace = true;
_value = _value.replace(playerName, "我");
}
if(_replace)
receiveParamters.put(_key, _value);
}
}
Map<String ,String> curInfoPoint = new HashMap<String, String>();
Solution bestMatch = null;
......
......@@ -195,8 +195,12 @@ public class GameBotUtil extends BasicBotUtil{
if(!curInfoPoint.containsKey(opPair[1]) || curInfoPoint.get(opPair[1]).equals("unknown") || curInfoPoint.get(opPair[1]).equals("")){
keyword = "not_exist";
}else {
logWriter.record("isNeighbour(" + chatCache.getInfoPoint().get("site") + "," + curInfoPoint.get(opPair[1]).split(":")[1] + ")", 1);
keyword = String.valueOf(chatCache.getGameEnv().isNeighbour(chatCache.getInfoPoint().get("site"), curInfoPoint.get(opPair[1]).split(":")[1]));
GameEnv gameEnv = chatCache.getGameEnv();
String _site = chatCache.getInfoPoint().get("site");
String _dest = curInfoPoint.get(opPair[1]).split(":")[1];
_dest = gameEnv.getPlaceNameByNickname(_site, _dest);
logWriter.record("isNeighbour(" + _site + "," + _dest + ")", 1);
keyword = String.valueOf(gameEnv.isNeighbour(_site, _dest));
logWriter.record("返回:" + keyword, 1);
}
}else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment