添加文本信息抽取接口

This commit is contained in:
2024-09-27 15:31:11 +08:00
parent 46be9a26be
commit 7a4cb5263a
4 changed files with 69 additions and 0 deletions

View File

@@ -22,6 +22,13 @@ def main():
return COST({'doc': img_path, 'layout': json.loads(layout)}) return COST({'doc': img_path, 'layout': json.loads(layout)})
@app.route('/text', methods=['POST'])
@process_request
def text():
t = request.form.get('text')
return COST(t)
if __name__ == '__main__': if __name__ == '__main__':
logging.config.dictConfig(LOGGING_CONFIG) logging.config.dictConfig(LOGGING_CONFIG)
app.run('0.0.0.0', 5004) app.run('0.0.0.0', 5004)

View File

@@ -24,6 +24,13 @@ def main():
return DISCHARGE({'doc': img_path, 'layout': json.loads(layout)}) return DISCHARGE({'doc': img_path, 'layout': json.loads(layout)})
@app.route('/text', methods=['POST'])
@process_request
def text():
t = request.form.get('text')
return DISCHARGE(t)
if __name__ == '__main__': if __name__ == '__main__':
logging.config.dictConfig(LOGGING_CONFIG) logging.config.dictConfig(LOGGING_CONFIG)
app.run('0.0.0.0', 5003) app.run('0.0.0.0', 5003)

View File

@@ -28,6 +28,13 @@ def main():
return SETTLEMENT_IE({'doc': img_path, 'layout': json.loads(layout)}) return SETTLEMENT_IE({'doc': img_path, 'layout': json.loads(layout)})
@app.route('/text', methods=['POST'])
@process_request
def text():
t = request.form.get('text')
return SETTLEMENT_IE(t)
if __name__ == '__main__': if __name__ == '__main__':
logging.config.dictConfig(LOGGING_CONFIG) logging.config.dictConfig(LOGGING_CONFIG)
app.run('0.0.0.0', 5002) app.run('0.0.0.0', 5002)

View File

@@ -38,6 +38,22 @@ def ie_settlement(img_path, layout):
return None return None
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
after=lambda x: logging.warning('从文本抽取基本医保结算单失败!'))
def ie_settlement(text):
"""
请求基本医保结算单信息抽取接口
:param text: 待抽取文本
:return: 抽取结果
"""
url = 'http://ie_settlement:5002/text'
response = requests.post(url, {'text': text})
if response.status_code == 200:
return response.json()
else:
return None
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True, @retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
after=lambda x: logging.warning('抽取出院记录失败!')) after=lambda x: logging.warning('抽取出院记录失败!'))
def ie_discharge(img_path, layout): def ie_discharge(img_path, layout):
@@ -55,6 +71,22 @@ def ie_discharge(img_path, layout):
return None return None
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
after=lambda x: logging.warning('从文本抽取出院记录失败!'))
def ie_discharge(text):
"""
请求出院记录信息抽取接口
:param text: 待抽取文本
:return: 抽取结果
"""
url = 'http://ie_discharge:5003/text'
response = requests.post(url, {'text': text})
if response.status_code == 200:
return response.json()
else:
return None
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True, @retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
after=lambda x: logging.warning('抽取费用清单失败!')) after=lambda x: logging.warning('抽取费用清单失败!'))
def ie_cost(img_path, layout): def ie_cost(img_path, layout):
@@ -72,6 +104,22 @@ def ie_cost(img_path, layout):
return None return None
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
after=lambda x: logging.warning('从文本抽取费用清单失败!'))
def ie_cost(text):
"""
请求费用清单信息抽取接口
:param text: 待抽取文本
:return: 抽取结果
"""
url = 'http://ie_cost:5004/text'
response = requests.post(url, {'text': text})
if response.status_code == 200:
return response.json()
else:
return None
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True, @retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
after=lambda x: logging.warning('获取图片方向失败!')) after=lambda x: logging.warning('获取图片方向失败!'))
def clas_orientation(img_path): def clas_orientation(img_path):