dujunlong 2 months ago
parent
commit
b1a1f5eb73

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


+ 2 - 2
final/ByRules/answer.py

@@ -273,8 +273,8 @@ if __name__ == "__main__":
     # question = "省间交易正在组织的交易有多少?"
     # question = "当前交易电量是多少?"
     # question = "2023年省间交易电量按交易周期划分的电量是多少?"
-    question = "2023年省间交易电量新能源交易电量是多少?"
-    # question = "省间交易正在组织的交易有多少?"
+    # question = "2023年省间交易电量新能源交易电量是多少?"
+    question = "省间交易正在组织的交易有多少?"
     # question = "省间交易当月完成的交易有多少?"
     # question = "省间交易当年完成的交易有多少?"
     # question = "省间交易当年达成的电量有多少?"

+ 23 - 22
final/ByRules/similarity_answer_json.py

@@ -462,12 +462,13 @@ def find_key_recursively(data, target_key):
     _search(data)
     return results
 # query = "当月省间交易完成的交易是多少?"
+query = "2023年累计省间交易电量是多少??"
 # query = "2024年1月到2月累计交易电量是多少?"
-query = "2024年12月交易电量是多少?"
-# query = "但同样阿贾克斯大口径的话我可合金外壳设计文件突然发?"
+# query = "2024年12月交易电量是多少?"
+# # query = "但同样阿贾克斯大口径的话我可合金外壳设计文件突然发?"
 json_folder = "templatesJson"
-
-
+#
+#
 result = process_query(query, template_dict, json_folder)
 
 print("匹配的模板 key:", result["matched_key"])
@@ -481,24 +482,24 @@ print("条件", result["conditions"])
 print("返回的内容是:", result["content"])
 print("问句是:", result["query"])
 print("动作是:", result["play"])
-
-type = result["type"]
-content = result["content"]
-
-json_data_folder = "..\Json\json_data"
-if type == "query":
-    fileName = result["dataJsonName"]
-    result = smart_find_value(json_data_folder, fileName,result["conditions"],result["target"] )
-    print(result)
-elif type == "calculate":
-    conditions = result["conditions"]
-    start_conditions = {('年' if 'year' in k else '月'): v for k, v in conditions.items() if k.startswith('start_')}
-    end_conditions = {('年' if 'year' in k else '月'): v for k, v in conditions.items() if k.startswith('end_')}
-    print(start_conditions)
-    print(end_conditions)
-    fileName = result["dataJsonName"] + ".json"
-    result = calculate_sum_by_time_range(json_data_folder,fileName,result["target"],start_conditions, end_conditions)
-    print(result)
+#
+# type = result["type"]
+# content = result["content"]
+#
+# json_data_folder = "..\Json\json_data"
+# if type == "query":
+#     fileName = result["dataJsonName"]
+#     result = smart_find_value(json_data_folder, fileName,result["conditions"],result["target"] )
+#     print(result)
+# elif type == "calculate":
+#     conditions = result["conditions"]
+#     start_conditions = {('年' if 'year' in k else '月'): v for k, v in conditions.items() if k.startswith('start_')}
+#     end_conditions = {('年' if 'year' in k else '月'): v for k, v in conditions.items() if k.startswith('end_')}
+#     print(start_conditions)
+#     print(end_conditions)
+#     fileName = result["dataJsonName"] + ".json"
+#     result = calculate_sum_by_time_range(json_data_folder,fileName,result["target"],start_conditions, end_conditions)
+#     print(result)
 #
 # # 最终回答的文本
 # final_content = content.replace("?", str(result))