mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-02-05 17:28:23 +08:00
测试新的模块引导,支持提交说明
This commit is contained in:
parent
eb9a4c7494
commit
b3d77529d0
22
package/test/text.py
Normal file
22
package/test/text.py
Normal 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)
|
Loading…
x
Reference in New Issue
Block a user