Browse Source

完成t5单条预测版本,引号中有句号处理

master
majiahui@haimaqingfan.com 2 years ago
parent
commit
570186ff64
  1. 9
      flask_predict_no_batch_t5.py

9
flask_predict_no_batch_t5.py

@ -1,7 +1,7 @@
import os import os
# os.environ["TF_KERAS"] = "1" # os.environ["TF_KERAS"] = "1"
# os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" # os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
# os.environ["CUDA_VISIBLE_DEVICES"] = "1" # os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
from flask import Flask, jsonify from flask import Flask, jsonify
from flask import request from flask import request
# from linshi import autotitle # from linshi import autotitle
@ -45,11 +45,18 @@ def get_dialogs_index(line: str):
def chulichangju_1(text, snetence_id, chulipangban_return_list, short_num): def chulichangju_1(text, snetence_id, chulipangban_return_list, short_num):
fuhao = ["","","",""] fuhao = ["","","",""]
dialogs_text, dialogs_index, other_index = get_dialogs_index(text)
print(len(text))
text_1 = text[:120] text_1 = text[:120]
text_2 = text[120:] text_2 = text[120:]
text_1_new = "" text_1_new = ""
if text_2 == "":
chulipangban_return_list.append([text_1, snetence_id, short_num])
return chulipangban_return_list
for i in range(len(text_1)-1, -1, -1): for i in range(len(text_1)-1, -1, -1):
if text_1[i] in fuhao: if text_1[i] in fuhao:
if i in dialogs_index:
continue
text_1_new = text_1[:i] text_1_new = text_1[:i]
text_1_new += text_1[i] text_1_new += text_1[i]
chulipangban_return_list.append([text_1_new, snetence_id, short_num]) chulipangban_return_list.append([text_1_new, snetence_id, short_num])

Loading…
Cancel
Save