2 Star 30 Fork 7

李子/Sound_File_Processing

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
change_transcript.py 2.92 KB
一键复制 编辑 原始数据 按行查看 历史
李子 提交于 2021-10-14 06:20 . 更正字符串处理
"""
修改transcript文件
"""
import re
def file_r(path):
with open(path, 'r', encoding="UTF-8") as f:
return f.read()
def file_w(path, text, mode, encoding="UTF-8"):
"""
用于向文件中写入
:param path: 文件路径
:param text: 要写入的数据
:param mode: 写入模式 a为追加 w为覆写
:param encoding: 文档编码格式
"""
with open(path, mode, encoding=encoding) as f:
f.write(text)
if __name__ == '__main__':
file_str = file_r("transcript/1.txt")
file_str = file_str.replace("非3星结束行动", "fei3xingjieshurenwu")
file_str = file_str.replace("3星结束行动", "3xingjieshurenwu")
file_str = file_str.replace("4星结束行动", "4xingjieshurenwu")
file_str = file_str.replace("编入队伍", "bianruduiwu")
file_str = file_str.replace("标题", "biaoti")
file_str = file_str.replace("部署1", "bushu1")
file_str = file_str.replace("部署2", "bushu2")
file_str = file_str.replace("戳一下", "chuoyixia")
file_str = file_str.replace("干员报到", "ganyuanbaodao")
file_str = file_str.replace("观看作战记录", "guankanzuozhanjilu")
file_str = file_str.replace("进驻设施", "jinzhusheshi")
file_str = file_str.replace("晋升后交谈1", "jinshenghoujiaotan1")
file_str = file_str.replace("晋升后交谈2", "jinshenghoujiaotan2")
file_str = file_str.replace("精英化晋升1", "jingyinghuajinsheng1")
file_str = file_str.replace("精英化晋升2", "jingyinghuajinsheng2")
file_str = file_str.replace("任命队长", "renmingduizhang")
file_str = file_str.replace("任命助理", "renmingzhuli")
file_str = file_str.replace("问候", "wenhou")
file_str = file_str.replace("闲置", "xianzhi")
file_str = file_str.replace("信赖触摸", "xinlaichumo")
file_str = file_str.replace("信赖提升后交谈1", "xinlaitishenghoujiaotan1")
file_str = file_str.replace("信赖提升后交谈2", "xinlaitishenghoujiaotan2")
file_str = file_str.replace("信赖提升后交谈3", "xinlaitishenghoujiaotan3")
file_str = file_str.replace("行动出发", "xingdongchufa")
file_str = file_str.replace("行动开始", "xingdongkaishi")
file_str = file_str.replace("行动失败", "xingdongshibai")
file_str = file_str.replace("选中干员1", "xuanzhongganyuan1")
file_str = file_str.replace("选中干员2", "xuanzhongganyuan2")
file_str = file_str.replace("作战中1", "zuozhanzhong1")
file_str = file_str.replace("作战中2", "zuozhanzhong2")
file_str = file_str.replace("作战中3", "zuozhanzhong3")
file_str = file_str.replace("作战中4", "zuozhanzhong4")
file_str = file_str.replace("交谈1", "jiaotan1")
file_str = file_str.replace("交谈2", "jiaotan2")
file_str = file_str.replace("交谈3", "jiaotan3")
file_str = re.sub(r"[~?,!。“”]|\([^\n]*\)|\.", "", file_str)
print(file_str)
file_w("transcript/1.txt", file_str, "w")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/kslizi/Sound_File_Processing.git
git@gitee.com:kslizi/Sound_File_Processing.git
kslizi
Sound_File_Processing
Sound_File_Processing
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385