Browse Source

Merge branch 'master' of http://120.24.5.168:8050/dujunlong/bjqa

dujunlong 2 months ago
parent
commit
0571937a23

BIN
final/ByRules/__pycache__/commonUtil.cpython-39.pyc


BIN
final/ByRules/__pycache__/similarity_answer_json.cpython-39.pyc


BIN
final/ByRules/__pycache__/util.cpython-39.pyc


+ 16 - 6
final/ByRules/app.py

@@ -58,7 +58,12 @@ def process_query_route():
             return jsonify(response)
         #  查询类问题:
         if result['type'] == 'query':
-            final_value = smart_find_value(DATA_FOLDER, result["dataJsonName"], result["conditions"], result["target"])
+            if result["flag"]:
+                final_value = smart_find_value(DATA_FOLDER, result["dataJsonName"], result["conditions"], result["target"])
+                final_value = final_value[0]
+            else:
+                final_value = smart_find_value(DATA_FOLDER, result["dataJsonName"], result["conditions"],
+                                               result["target"])
             final_content = result["content"].replace("&", str(final_value))
             # final_content = fill_template_auto(result['content'], final_value)
             response = {
@@ -67,7 +72,8 @@ def process_query_route():
                 "raw_result": final_value,
                 "conditions": result["conditions"],
                 "name": result["name"],
-                "play": result["play"]
+                "play": result["play"],
+                "unit": result["unit"],
             }
             return jsonify(response)
         # 计算类问题
@@ -86,7 +92,8 @@ def process_query_route():
                 "raw_result": final_value,
                 "conditions": result["conditions"],
                 "name": result["name"],
-                "play": result["play"]
+                "play": result["play"],
+                "unit": result["unit"],
             }
             return jsonify(response)
         # 最值类问题
@@ -107,7 +114,8 @@ def process_query_route():
                 "raw_result": final_value,
                 "conditions": result["conditions"],
                 "name": result["name"],
-                "play": result["play"]
+                "play": result["play"],
+                "unit": result["unit"],
             }
             return jsonify(response)
         # TopN
@@ -132,7 +140,8 @@ def process_query_route():
                 "raw_result": final_value,
                 "conditions": result["conditions"],
                 "name": result["name"],
-                "play": result["play"]
+                "play": result["play"],
+                "unit": result["unit"],
             }
             return jsonify(response)
         # TopN
@@ -162,7 +171,8 @@ def process_query_route():
                 "conditions": result["conditions"],
                 "name": result["name"],
                 "play": result["play"],
-                "qcode": result["qcode"]
+                "qcode": result["qcode"],
+                "unit": result["unit"],
             }
             return jsonify(response)
     except Exception as e:

+ 5 - 1
final/ByRules/similarity_answer_json.py

@@ -521,6 +521,8 @@ def process_query(query, template_dict, json_folder, tokenizer=jieba_tokenizer):
     content = template_info.get("content", "")
     play = template_info.get("play", "")
     qcode = template_info.get("qcode", "")
+    unit = template_info.get("unit", "")
+    flag = template_info.get("flag", "")
 
     return {
         "matched_key": matched_key,
@@ -538,7 +540,9 @@ def process_query(query, template_dict, json_folder, tokenizer=jieba_tokenizer):
         "find_max": find_max,
         "value_key": value_key,
         "name_key": name_key,
-        "qcode": qcode
+        "qcode": qcode,
+        "unit": unit,
+        "flag": flag
     }
 # 查询类
 def smart_find_value(folder_path, file_name, conditions: dict, target_key: str):

+ 2 - 1
final/ByRules/templatesJson/19.json

@@ -6,5 +6,6 @@
   "content": "省间交易正在组织的交易为&",
   "play": "讲述文本",
   "name": "省间交易组织",
-  "unit": "笔"
+  "unit": "笔",
+  "flag": "True"
 }

+ 2 - 1
final/ByRules/templatesJson/20.json

@@ -6,5 +6,6 @@
   "content": "省间交易当月完成的交易为&",
   "play": "讲述文本",
   "name": "省间交易组织",
-  "unit": "笔"
+  "unit": "笔",
+  "flag": "True"
 }

+ 2 - 1
final/ByRules/templatesJson/21.json

@@ -6,5 +6,6 @@
   "content": "省间交易当年完成的交易为&",
   "play": "讲述文本",
   "name": "省间交易组织",
-  "unit": "笔"
+  "unit": "笔",
+  "flag": "True"
 }

+ 2 - 1
final/ByRules/templatesJson/22.json

@@ -6,5 +6,6 @@
   "content": "省间交易当年达成的电量为&",
   "play": "讲述文本",
   "name": "省间交易组织",
-  "unit": "笔"
+  "unit": "笔",
+  "flag": "True"
 }

+ 2 - 1
final/ByRules/templatesJson/23.json

@@ -6,5 +6,6 @@
   "content": "省间交易当年参与交易的家次为&",
   "play": "讲述文本",
   "name": "省间交易组织",
-  "unit": "家"
+  "unit": "家",
+  "flag": "True"
 }