From 2f188a3dc6c74806c22ebc56d8c9ea261a9bf68a Mon Sep 17 00:00:00 2001 From: liuyebo <1515783401@qq.com> Date: Mon, 1 Jul 2024 14:57:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4taskflow=E7=9A=84=E7=94=9F?= =?UTF-8?q?=E6=88=90=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- photo_review/photo_review.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/photo_review/photo_review.py b/photo_review/photo_review.py index bec0b21..35f6d8a 100644 --- a/photo_review/photo_review.py +++ b/photo_review/photo_review.py @@ -290,7 +290,7 @@ def save_or_update_ie(table, pk_phhd, data): session.close() -def photo_review(pk_phhd, task_flows): +def photo_review(pk_phhd): settlement_list = [] discharge_record = [] cost_list = [] @@ -308,7 +308,9 @@ def photo_review(pk_phhd, task_flows): elif phrec.cRectype == "4": cost_list.append(phrec) - settlement_list_ie_result = information_extraction(task_flows[0], settlement_list) + settlement_list_ie_result = information_extraction( + Taskflow("information_extraction", schema=SETTLEMENT_LIST_SCHEMA, model="uie-x-base", + task_path="config/model/settlement_list_model", layout_analysis=LAYOUT_ANALYSIS), settlement_list) settlement_data = { "pk_phhd": pk_phhd, "name": handle_name(get_best_value_in_keys(settlement_list_ie_result, PATIENT_NAME)), @@ -334,7 +336,9 @@ def photo_review(pk_phhd, task_flows): settlement_data["personal_funded_amount"] = handle_decimal(settlement_data["personal_funded_amount_str"]) save_or_update_ie(ZxIeSettlement, pk_phhd, settlement_data) - discharge_record_ie_result = information_extraction(task_flows[1], discharge_record) + discharge_record_ie_result = information_extraction( + Taskflow("information_extraction", schema=DISCHARGE_RECORD_SCHEMA, model="uie-x-base", + task_path="config/model/discharge_record_model", layout_analysis=LAYOUT_ANALYSIS), discharge_record) discharge_data = { "pk_phhd": pk_phhd, "hospital": handle_hospital(get_best_value_in_keys(discharge_record_ie_result, HOSPITAL)), @@ -371,7 +375,9 @@ def photo_review(pk_phhd, task_flows): discharge_data["department"] = ylks.name save_or_update_ie(ZxIeDischarge, pk_phhd, discharge_data) - cost_list_ie_result = information_extraction(task_flows[2], cost_list) + cost_list_ie_result = information_extraction( + Taskflow("information_extraction", schema=COST_LIST_SCHEMA, model="uie-x-base", + task_path="config/model/cost_list_model", layout_analysis=LAYOUT_ANALYSIS), cost_list) cost_data = { "pk_phhd": pk_phhd, "name": handle_name(get_best_value_in_keys(cost_list_ie_result, PATIENT_NAME)), @@ -393,18 +399,10 @@ def main(): phhds = session.query(ZxPhhd.pk_phhd).filter(ZxPhhd.exsuccess_flag == '1').limit(PHHD_BATCH_SIZE).all() session.close() if phhds: - ie_task_flows = [ - Taskflow("information_extraction", schema=SETTLEMENT_LIST_SCHEMA, model="uie-x-base", - task_path="config/model/settlement_list_model", layout_analysis=LAYOUT_ANALYSIS), - Taskflow("information_extraction", schema=DISCHARGE_RECORD_SCHEMA, model="uie-x-base", - task_path="config/model/discharge_record_model", layout_analysis=LAYOUT_ANALYSIS), - Taskflow("information_extraction", schema=COST_LIST_SCHEMA, model="uie-x-base", - task_path="config/model/cost_list_model", layout_analysis=LAYOUT_ANALYSIS), - ] for phhd in phhds: pk_phhd = phhd.pk_phhd logging.info(f"开始识别:{pk_phhd}") - photo_review(pk_phhd, ie_task_flows) + photo_review(pk_phhd) # 识别完成更新标识 session = MysqlSession()