From 487d12b45f65bd396e2c6b7e0962b1eb01cf05e4 Mon Sep 17 00:00:00 2001 From: weiweiw Date: Thu, 27 Feb 2025 20:22:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E8=BD=AE=E9=97=AE=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/mian.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/api/mian.py b/api/mian.py index b17726f..882630d 100644 --- a/api/mian.py +++ b/api/mian.py @@ -12,7 +12,7 @@ from pydantic import ValidationError from intentRecognition import IntentRecognition from slotRecognition import SlotRecognition from fuzzywuzzy import process -from utils import CheckResult, StandardType +from utils import CheckResult, StandardType, load_standard_name from constants import PROJECT_NAME, PROJECT_DEPARTMENT # 常量 @@ -47,9 +47,9 @@ slot_recognizer = SlotRecognition(MODEL_UIE_PATH, label_map) # 设置Flask应用 #标准工程名 -standard_project_name_list = utils.load_standard_name('./standard_data/standard_project.txt') +standard_project_name_list = load_standard_name('./standard_data/standard_project.txt') #标准项目名 -standard_program_name_list = utils.load_standard_name('./standard_data/standard_program.txt') +standard_program_name_list = load_standard_name('./standard_data/standard_program.txt') app = Flask(__name__) @@ -209,7 +209,9 @@ def agent(): }) #工程名和项目名标准化 + print(f"start to check_project_standard_slot") result, information = check_project_standard_slot(predicted_id, entities) + print(f"end check_project_standard_slot,{result},{information}") if result == CheckResult.NEEDS_MORE_ROUNDS: return jsonify({ "code": 10001, "msg": "成功", @@ -286,11 +288,12 @@ def check_lost(int_res, slot): def check_project_standard_slot(int_res, slot) -> tuple: intention_list = {3, 4, 5, 6, 7, 8} if int_res not in intention_list: - return CheckResult.NO_MATCH,"" + return CheckResult.NO_MATCH, "" for key, value in slot.items(): if key == PROJECT_NAME: match_project, match_possibility = fuzzy_match(value, standard_project_name_list) + print(f"fuzzy_match project result:{match_project}, {match_possibility}") if match_possibility >= 0.9: slot[key] = match_project else: @@ -298,17 +301,18 @@ def check_project_standard_slot(int_res, slot) -> tuple: if key == PROJECT_DEPARTMENT: match_program, match_possibility = fuzzy_match(value, standard_program_name_list) + print(f"fuzzy_match program result:{match_program}, {match_possibility}") if match_possibility >= 0.9: slot[key] = match_program else: return CheckResult.NEEDS_MORE_ROUNDS, f"抱歉,您说的项目名是{match_program}吗" - return CheckResult.NO_MATCH,"" + return CheckResult.NO_MATCH, "" def fuzzy_match(user_input, standard_name): result = process.extract(user_input, standard_name) - return result[0], result[1]/100 + return result[0][0], result[0][1]/100 if __name__ == '__main__': app.run(host='0.0.0.0', port=18074, debug=True)