Commit c05ae468 by hxw2303632

删除没有用到的变量

parent 148904cb
......@@ -14,7 +14,6 @@ import static com.qiwu.chatbotbackend.Config.Config.TASK_REPLY;
public class MapConstructor extends ElementConstructor {
int[][] matrix;
int locationNum;
HashMap<Integer, JSONObject> id2j = new HashMap<Integer, JSONObject>();
Map<String, String> question2keyword = new HashMap<String, String>();
......@@ -43,14 +42,11 @@ public class MapConstructor extends ElementConstructor {
String locationName, taskLineName = "";
locationNum = locations.size();
StringBuffer nameSet = null;
keywordMap.putIfAbsent("site_list", new StringBuffer());
for (int i = 0; i < locationNum; i++) {
jobj = locations.getJSONObject(i);
jobj.put("index", i);
locationName = (String) jobj.get("name");
keywordMap.get("site_list").append("+").append(locationName);
taskLineName = String.format(TASK_LINE, locationName);
......@@ -61,44 +57,21 @@ public class MapConstructor extends ElementConstructor {
varInitialMap.put(taskLineName, "");
}
nameSet = new StringBuffer();
nameSet.append(locationName);
name2nickname.putIfAbsent(locationName, new ArrayList<>());
POS.append("=" + locationName + "|地名\r\n");
if(jobj.containsKey("nickname")){
for(String nickname:JSONArray.parseArray(locations.getJSONObject(i).getJSONArray("nickname").toJSONString(), String.class)){
if(!nickname.equals("")) {
nameSet.append("+").append(nickname);
POS.append("=").append(nickname).append("|地名\r\n");
name2nickname.get(locationName).add(nickname);
}
}
}
jobj.put("nameSet", nameSet.toString());
locationId = (Integer) jobj.get("id");
id2j.put(locationId, jobj);
}
//邻接矩阵初始化
matrix = new int[locationNum][locationNum];
for (int i = 0; i < locationNum; i++) {
for (int j = 0; j < locationNum; j++) {
matrix[i][j] = Integer.MAX_VALUE;
}
}
for (int i = 0; i < locationNum; i++) {
List<Integer> neighbours = JSONArray.parseArray(locations.getJSONObject(i).getJSONArray("neighbours").toJSONString(), Integer.class);
for (int neighbourId : neighbours) {
JSONObject neighbourObject = id2j.get(neighbourId);
//System.out.println(neighbourObject);
index = (Integer) neighbourObject.get("index");
matrix[i][index] = 1;
matrix[index][i] = 1;
}
}
}
......@@ -121,16 +94,13 @@ public class MapConstructor extends ElementConstructor {
}
JSONArray locations = map.getJSONArray("locations");
String userName = gameElements.getString("userName"), locationName;
String locationName;
this.locations = locations;
this.question2keyword = question2keyword;
//通过邻接表构造邻接矩阵
constructGreph(locations);
//用弗洛伊德算法求最短路径
//Floyd floyd = new Floyd();
//floyd.findShortestPath(matrix, locationNum);
//floyd.printPath(matrix, locationNum);
generateWantToThere(gameElements, keywordMap);
generateHowToThere(gameElements, keywordMap);
......@@ -190,7 +160,6 @@ public class MapConstructor extends ElementConstructor {
String conditionNameList[] = keywordMap.get(intent).toString().split(",");
StringBuffer placeKeywords = new StringBuffer();
String nameSet;
for(String conditionName:conditionNameList) {
......@@ -217,10 +186,6 @@ public class MapConstructor extends ElementConstructor {
placeKeywords.append(gotoSite);
//toSitekeywords.append(gotoSite);
}
//nameSet = (String) locations.getJSONObject(i).get("nameSet");
//placeKeywords.append("+").append(nameSet);
}
......
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