测试新的模块引导,支持提交说明

This commit is contained in:
asdf 2023-07-22 13:51:21 +08:00
parent eb9a4c7494
commit b3d77529d0

22
package/test/text.py Normal file
View File

@ -0,0 +1,22 @@
import re
def process_text(file_name, char_length, prompt):
with open(file_name, 'r', encoding='utf-8') as f:
content = f.readlines()
new_content = []
for line in content:
if not re.match(r"(\d+|\d+:\d+:\d+,\d+ --> \d+:\d+:\d+,\d+)", line.strip()):
new_content.append(line.strip())
text = "".join(new_content)
segments = [text[i:i+char_length] for i in range(0, len(text), char_length)]
with open('processed_' + file_name, 'w', encoding='utf-8') as f:
for i, segment in enumerate(segments):
f.write(f"{prompt}: {segment}\r\n\r\n\r\n")
# 使用脚本
prompt = "整理后面我发给你的培训录音去掉语气词将其改写为适合书面发表的语言并适当增加小标题用markdown的格式输出"
process_text('Section1.txt', 4000, prompt)