Commit dab996fa by 赵国君

属性更新问题修复

parent f4ead641
......@@ -1025,7 +1025,7 @@ public class ActionUtils {
}
}
}
if(extraKeywords != null && extraKeywords != "") {
if(extraKeywords != null && !extraKeywords.equals("")) {
conditionJson.put("relationHead", extraKeywords);
}
......@@ -1040,7 +1040,7 @@ public class ActionUtils {
}
}
}
if(extraKeywords != null && extraKeywords != "") {
if(extraKeywords != null && !extraKeywords.equals("")) {
conditionJson.getJSONArray("repeatList").getJSONObject(0).put("repeatKeywords", extraKeywords);
}
return true;
......
......@@ -105,10 +105,6 @@ public class ElementConstructor {
relationKeywords.put(conditionName + "_tail", new HashSet<String>());
}
//visitorname和bot的替换
// premise.put("keywords", ((String)premise.get("keywords")).replace("qiwu", "#visitorname").replace(botName, "#botname"));
premise.put("keywords", replaceKeywords((String)premise.get("keywords")));
for (String keyword : ((String) premise.get("keywords")).split("\\+")) {
if(keyword.equals("")){
......@@ -149,9 +145,7 @@ public class ElementConstructor {
relationKeywords.put(conditionName + "_tail", new HashSet<String>());
}
// premise.put("keywords", ((String)premise.get("keywords")).replace("qiwu", "#visitorname").replace(botName, "#botname"));
premise.put("keywords", replaceKeywords((String)premise.get("keywords")));
for (String keyword : ((String) premise.get("keywords")).split("\\+")) {
if(keyword.equals("")){
......@@ -176,43 +170,6 @@ public class ElementConstructor {
}
}
public String replaceKeywords(String str) {
Boolean startChat = str.startsWith("+");
Map<String, String> keywords = new HashMap<>();
keywords.put("qiwu", "#visitorname");
keywords.put("我", "#visitorname");
keywords.put("botName", "#botname");
keywords.put("你", "#botname");
String[] split = str.split("\\+");
String _s;
int pos;
String sub1;
String sub2;
for(int i =0; i < split.length; ++i) {
_s = split[i];
pos = _s.indexOf(":");
if(pos == -1) {
if (keywords.get(_s) != null) {
_s = keywords.get(_s);
}
} else {
sub1 = _s.substring(0, pos);
sub2 = _s.substring(pos+1, _s.length());
if (keywords.get(sub1) != null) {
sub1 = keywords.get(sub1);
}
if (keywords.get(sub2) != null) {
sub2 = keywords.get(sub2);
}
_s = sub1 + ":" + sub2;
}
split[i] = _s;
}
str = String.join("+", split);
if(!str.equals("") && startChat && !str.startsWith("+"))
str = "+" + str;
return str;
}
/**
* 根据插入的数据做后处理
......
......@@ -895,7 +895,26 @@ public class ActionMatcher {
keyword = botUtil.getKeyword(historyInfoPoint, curInfoPoint, false, variableName);
updateValue = botUtil.knowledgeProcess(variableName, action.getUpdateKnowledge().get(variableName));
int indexOf = variableName.indexOf("_");
if(indexOf != -1) {
String prefix = variableName.substring(0, indexOf);
if(prefix.equals("npc") || prefix.equals("goods") || prefix.equals("map") || prefix.equals("place")) {
String[] split = variableName.split("_");
if(split.length == 4) {
String _type = split[0];
switch(_type) {
case("npc"):
keyword = gameEnv.queryNpcAttrByNpcName(split[2], split[3]);
break;
case("goods"):
keyword = gameEnv.queryGoodsAttrByGoodsName(split[2], split[3]);
break;
default:
break;
}
}
}
}
try {
//做数字加法
......
......@@ -42,7 +42,7 @@ public class ChatCacheTests {
//先删除就数据
SqlHelper helper = new SqlHelper();
ChatCacheController.deleteChatCache(helper, "123456789");
// ChatCacheController.deleteChatCache(helper, "123456789");
Map<String, ChatCache> chatCacheMap = null;
chatCacheMap = new HashMap<String, ChatCache>();
......
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