
7 changed files with 231 additions and 80 deletions
@ -0,0 +1,41 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
""" |
||||
|
@Time : 2023/2/21 11:28 |
||||
|
@Author : |
||||
|
@FileName: |
||||
|
@Software: |
||||
|
@Describe: |
||||
|
""" |
||||
|
import os |
||||
|
def read_text(file): |
||||
|
try: |
||||
|
with open(file, 'r', encoding="utf-8") as f: |
||||
|
lines = [x.strip() for x in f if x.strip() != ''] |
||||
|
except: |
||||
|
with open(file, 'r', encoding="gbk") as f: |
||||
|
lines = [x.strip() for x in f if x.strip() != ''] |
||||
|
return lines |
||||
|
|
||||
|
|
||||
|
if __name__ == '__main__': |
||||
|
|
||||
|
path = '../data/11篇txt' |
||||
|
path_new = '../data/11篇汇总txt.txt' |
||||
|
path_list = [] |
||||
|
data = [] |
||||
|
|
||||
|
for file_name in os.listdir(path): |
||||
|
path_list.append(file_name) |
||||
|
for docx_name in path_list: |
||||
|
df_list_new = [] |
||||
|
with open(path + "/" + docx_name, 'r', encoding="utf-8") as f: |
||||
|
lines = [x.strip() for x in f if x.strip() != ''] |
||||
|
data.extend(lines) |
||||
|
data.append("+++++++++++++++++++++++++++++++++++++++++++++++++@@@@@@@@@@@@@@@@@@@") |
||||
|
|
||||
|
|
||||
|
with open(path_new, "w", encoding='utf-8') as file: |
||||
|
for i in data: |
||||
|
file.write(i + '\n') |
||||
|
file.close() |
@ -0,0 +1,30 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
""" |
||||
|
@Time : 2023/2/21 11:51 |
||||
|
@Author : |
||||
|
@FileName: |
||||
|
@Software: |
||||
|
@Describe: |
||||
|
""" |
||||
|
|
||||
|
path = '../data/11篇汇总txt.txt' |
||||
|
path_new = '../data/11篇汇总txt_new.txt' |
||||
|
with open(path, 'r', encoding="utf-8") as f: |
||||
|
lines = [x.strip() for x in f if x.strip() != ''] |
||||
|
|
||||
|
data = [] |
||||
|
for i in lines: |
||||
|
dan = i.strip() |
||||
|
print(dan) |
||||
|
if dan == "。": |
||||
|
continue |
||||
|
elif dan == "+++++++++++++++++++++++++++++++++++++++++++++++++@@@@@@@@@@@@@@@@@@@": |
||||
|
data.append("嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯嚯") |
||||
|
else: |
||||
|
data.append(dan) |
||||
|
|
||||
|
with open(path_new, "w", encoding='utf-8') as file: |
||||
|
for i in data: |
||||
|
file.write(i + '\n') |
||||
|
file.close() |
@ -0,0 +1,59 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
""" |
||||
|
@Time : 2022/12/29 1:14 |
||||
|
@Author : |
||||
|
@FileName: |
||||
|
@Software: |
||||
|
@Describe: |
||||
|
""" |
||||
|
#coding:utf-8 |
||||
|
|
||||
|
import requests |
||||
|
from time import time |
||||
|
|
||||
|
def dialog_line_parse(url, text): |
||||
|
""" |
||||
|
将数据输入模型进行分析并输出结果 |
||||
|
:param url: 模型url |
||||
|
:param text: 进入模型的数据 |
||||
|
:return: 模型返回结果 |
||||
|
""" |
||||
|
|
||||
|
response = requests.post( |
||||
|
url, |
||||
|
json=text, |
||||
|
timeout=1000 |
||||
|
) |
||||
|
if response.status_code == 200: |
||||
|
return response.json() |
||||
|
else: |
||||
|
# logger.error( |
||||
|
# "【{}】 Failed to get a proper response from remote " |
||||
|
# "server. Status Code: {}. Response: {}" |
||||
|
# "".format(url, response.status_code, response.text) |
||||
|
# ) |
||||
|
print("【{}】 Failed to get a proper response from remote " |
||||
|
"server. Status Code: {}. Response: {}" |
||||
|
"".format(url, response.status_code, response.text)) |
||||
|
print(text) |
||||
|
return [] |
||||
|
|
||||
|
|
||||
|
ceshi_1 = [ |
||||
|
"李正旺你真是傻逼讪笑,挥手道:“不不不,你千万别误会。关于这件事,校长特别交代过了,我也非常认同。你这是见义勇为,是勇斗歹徒、义救同学的英雄,我们清江一中决不让英雄流血又流泪!”。", |
||||
|
"李正旺你真是傻逼讪笑,挥手道:“不不不,你千万别误会。关于这件事,校长特别交代过了,我也非常认同。", |
||||
|
"李正旺你真是傻逼讪笑,挥手道:“不不不,你千万别误会。关于这件事,校长特别交代过了,我也非常认同。" |
||||
|
"我" * 110 |
||||
|
] |
||||
|
|
||||
|
jishu = 0 |
||||
|
for i in ceshi_1: |
||||
|
for j in i: |
||||
|
jishu += 1 |
||||
|
print(jishu) |
||||
|
|
||||
|
t1 = time() |
||||
|
print(dialog_line_parse("http://114.116.25.228:14000/droprepeat/",{"texts": ceshi_1, "text_type": "focus"})) |
||||
|
t2 = time() |
||||
|
print(t2 -t1) |
Loading…
Reference in new issue