优化案子处理逻辑
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
import logging
|
||||
import os.path
|
||||
|
||||
import requests
|
||||
from tenacity import retry, stop_after_attempt, wait_random
|
||||
@@ -16,9 +17,10 @@ def ocr(img_path):
|
||||
url = 'http://ocr:5001'
|
||||
response = requests.post(url, {'img_path': img_path})
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
else:
|
||||
return None
|
||||
ocr_result = response.json()
|
||||
if ocr_result:
|
||||
return ocr_result[0]
|
||||
return None
|
||||
|
||||
|
||||
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
|
||||
@@ -40,7 +42,7 @@ def ie_settlement(img_path, layout):
|
||||
|
||||
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
|
||||
after=lambda x: logging.warning('从文本抽取基本医保结算单失败!'))
|
||||
def ie_settlement(text):
|
||||
def ie_settlement_text(text):
|
||||
"""
|
||||
请求基本医保结算单信息抽取接口
|
||||
:param text: 待抽取文本
|
||||
@@ -73,7 +75,7 @@ def ie_discharge(img_path, layout):
|
||||
|
||||
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
|
||||
after=lambda x: logging.warning('从文本抽取出院记录失败!'))
|
||||
def ie_discharge(text):
|
||||
def ie_discharge_text(text):
|
||||
"""
|
||||
请求出院记录信息抽取接口
|
||||
:param text: 待抽取文本
|
||||
@@ -106,7 +108,7 @@ def ie_cost(img_path, layout):
|
||||
|
||||
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
|
||||
after=lambda x: logging.warning('从文本抽取费用清单失败!'))
|
||||
def ie_cost(text):
|
||||
def ie_cost_text(text):
|
||||
"""
|
||||
请求费用清单信息抽取接口
|
||||
:param text: 待抽取文本
|
||||
@@ -147,9 +149,22 @@ def det_book(img_path):
|
||||
url = 'http://det_book:5006'
|
||||
response = requests.post(url, {'img_path': img_path})
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
book_path_list = response.json()
|
||||
if len(book_path_list) == 0:
|
||||
return img_path
|
||||
elif len(book_path_list) == 1:
|
||||
return book_path_list[0]
|
||||
else:
|
||||
max_book = img_path
|
||||
max_size = 0
|
||||
for book_path in book_path_list:
|
||||
book_size = os.path.getsize(book_path)
|
||||
if book_size > max_size:
|
||||
max_book = book_path
|
||||
max_size = book_size
|
||||
return max_book
|
||||
else:
|
||||
return [img_path]
|
||||
return img_path
|
||||
|
||||
|
||||
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
|
||||
|
||||
Reference in New Issue
Block a user