import sys | |
sys.path.append('..') | |
from common import clearT, get_all_files_in_directory | |
# https://huggingface.co/datasets/Limour/archvie/blob/main/v-corpus-zh/common.py | |
# ================= | |
a = get_all_files_in_directory(r'E:\galgame\霞流宝石心\json_cn', ext='.json') | |
b = r'E:\galgame\霞流宝石心\text' | |
# ================= | |
sc = {} | |
_n = { | |
"美杜莎士兵" : "美杜莎士兵", | |
"宗真" : "宗真", | |
"维欧" : "维欧", | |
"贝尔卡" : "贝尔卡", | |
"鸡蛇兽" : "鸡蛇兽", | |
"马库斯" : "马库斯", | |
"爱莉安娜" : "爱莉安娜", | |
"映红" : "映红", | |
"???" : "?", | |
"路旁的山羊" : "路旁的山羊", | |
"货郎" : "货郎", | |
"队长" : "队长", | |
"满怀期待的新生" : "满怀期待的新生", | |
"冷漠的新生" : "冷漠的新生", | |
"雷蒙德老师" : "雷蒙德老师", | |
"数学教授" : "数学教授", | |
"西蒙" : "西蒙", | |
"娜塔莎" : "娜塔莎", | |
"天文学教授" : "天文学教授", | |
"博物学教授" : "博物学教授", | |
"修辞学教授" : "修辞学教授", | |
"卡拉" : "卡拉", | |
"金发男生" : "金发男生", | |
"兽人男生" : "兽人男生", | |
"女生" : "女生", | |
"兽人少女" : "兽人少女", | |
"神秘的女生" : "神秘的女生", | |
"银发少女" : "银发少女", | |
"成熟的女性" : "成熟的女性", | |
"班主任" : "班主任", | |
"夏洛特" : "夏洛特", | |
"梅尔" : "梅尔", | |
"全员" : "全员", | |
"校长" : "校长", | |
"弗雷德" : "弗雷德", | |
"屋顶" : "屋顶", | |
"图书管理员" : "图书管理员", | |
"学生1" : "学生1", | |
"学生2" : "学生2", | |
"老管家" : "老管家", | |
"校工" : "校工", | |
"趾高气扬的男生" : "趾高气扬的男生", | |
"豹形兽人" : "豹形兽人", | |
"奇德鲁" : "奇德鲁", | |
"魔犬" : "魔犬", | |
"雨菊" : "雨菊", | |
"其他班的学生1" : "其他班的学生1", | |
"其他班的学生2" : "其他班的学生2", | |
"约瑟夫" : "约瑟夫", | |
"艾米莉" : "艾米莉", | |
"扎克" : "扎克", | |
"科莉特" : "科莉特", | |
"安迪" : "安迪", | |
"沉默的男子" : "沉默的男子", | |
"赤兔" : "赤兔", | |
"伊莉雅" : "伊莉雅", | |
"让" : "让", | |
"亨特" : "亨特", | |
"达里尔" : "达里尔", | |
"贝尔卡&维欧" : "贝尔卡&维欧", | |
"比伊" : "比伊", | |
"艾伦" : "艾伦", | |
"伊恩" : "伊恩", | |
"特德" : "特德", | |
"大家" : "大家", | |
"?" : "?", | |
"塞西莉亚" : "塞西莉亚", | |
"格泽尔曼" : "格泽尔曼", | |
"希" : "希", | |
"持剑男人" : "持剑男人", | |
"可疑女子" : "可疑女子", | |
"菲利普" : "菲利普", | |
"野蛇" : "野蛇", | |
"卡罗琳娜" : "卡罗琳娜", | |
"小凯露" : "小凯露", | |
"绿色眼镜蛇" : "绿色眼镜蛇", | |
"男人的声音" : "男人的声音", | |
"军人" : "军人", | |
"保安" : "保安", | |
"梅纳德" : "梅纳德", | |
"盗贼啰喽" : "盗贼啰喽", | |
"盗贼头目" : "盗贼头目", | |
"路人" : "路人", | |
"弗里吉亚卫兵" : "弗里吉亚卫兵", | |
"涅斯托尔士官长" : "涅斯托尔士官长", | |
"里卡多" : "里卡多", | |
"肯内特" : "肯内特", | |
"女性情报官" : "女性情报官", | |
"华生" : "华生", | |
"多萝西" : "多萝西", | |
"弗里吉亚士兵" : "弗里吉亚士兵", | |
"勇敢的高年级学生" : "勇敢的高年级学生", | |
"持双剑的高年级生" : "持双剑的高年级生", | |
"诺亚" : "诺亚", | |
"两人一齐" : "两人一齐", | |
"卡拉的母亲" : "卡拉的母亲", | |
"卡拉的父亲" : "卡拉的父亲", | |
"妖艳女人" : "妖艳女人", | |
"露西尔" : "露西尔", | |
"克拉拉" : "克拉拉", | |
"埃玛" : "埃玛", | |
"神秘广播" : "神秘广播", | |
"巴西利斯克" : "巴西利斯克", | |
"弗里吉亚众士兵" : "弗里吉亚众士兵", | |
"吉梅尔" : "吉梅尔", | |
"亨利" : "亨利", | |
"卡米拉" : "卡米拉", | |
"艾内骑士" : "艾内骑士", | |
"丹准将" : "丹准将", | |
"亚特拉斯市民" : "亚特拉斯市民", | |
"克里斯蒂安" : "克里斯蒂安", | |
"加夫百炼队" : "加夫百炼队", | |
"胡狼兽人" : "胡狼兽人", | |
"店老板" : "店老板", | |
"卖报人" : "卖报人", | |
"魔像人偶" : "魔像人偶", | |
"收音机中" : "收音机中", | |
"贝尔卡&宗真" : "贝尔卡&宗真", | |
"老人的声音" : "老人的声音", | |
"拉姆达" : "拉姆达", | |
"卡帕" : "卡帕", | |
"奔逃的老人" : "奔逃的老人", | |
"我们" : "我们", | |
"敏捷的魔像人偶" : "敏捷的魔像人偶", | |
"帕拉斯" : "帕拉斯", | |
"克希" : "克希", | |
"罗" : "罗", | |
"西塔" : "西塔", | |
"努" : "努", | |
"约塔" : "约塔", | |
"艾什礼" : "艾什礼", | |
"佩克" : "佩克", | |
"母亲的声音" : "母亲的声音", | |
"父亲的声音" : "父亲的声音", | |
"石像的呻吟" : "石像的呻吟", | |
"美杜莎士兵?" : "美杜莎士兵?", | |
"鸡蛇兽?" : "鸡蛇兽?", | |
"神秘生命" : "神秘生命", | |
"宗真&映红" : "宗真&映红", | |
"示威群众" : "示威群众", | |
"弗里吉亚皇帝" : "弗里吉亚皇帝", | |
"格伦" : "格伦", | |
"鲁克" : "鲁克", | |
"凯特" : "凯特", | |
"奔逃的女人" : "奔逃的女人", | |
"特洛伊士兵" : "特洛伊士兵", | |
"瓦尼教国使节" : "瓦尼教国使节", | |
"亚该亚使节" : "亚该亚使节", | |
"卡里亚代表" : "卡里亚代表", | |
"男杀手" : "男杀手", | |
"柯尔" : "柯尔", | |
"齐声" : "齐声", | |
"紫发女人" : "紫发女人", | |
"迷路少女" : "迷路少女", | |
"利布拉" : "利布拉", | |
"人类女子" : "人类女子", | |
"齐格" : "齐格", | |
"保罗" : "保罗", | |
"梅耶尔" : "梅耶尔", | |
"二人" : "二人", | |
"三人一齐" : "三人一齐", | |
"尤瑞艾莉" : "尤瑞艾莉", | |
"格泽尔曼一世" : "格泽尔曼一世", | |
"毒蛇" : "毒蛇", | |
"充满眷恋的声音" : "充满眷恋的声音", | |
"花枝招展的女人" : "花枝招展的女人", | |
"、贝尔卡" : "贝尔卡" | |
} | |
# ================= | |
import json | |
import re | |
reg_q = re.compile(r'[?\s]+') | |
for path in a: | |
name = path[path.rindex('\\') + 1:] | |
name = '0' | |
if name not in sc: | |
sc[name] = [] | |
print(name) | |
# ================= | |
with open(path, 'r', encoding='utf-8') as json_file: | |
data = json.load(json_file) | |
# ================= | |
for line in data: | |
if 'name' in line: | |
n = line['name'] | |
if n in _n: | |
n = _n[n] | |
else: | |
tmp = clearT(n).replace('・', '&') | |
tmp = reg_q.sub('?', tmp) | |
_n[n] = tmp.split('//')[-1].replace(' ', '') | |
print(line, n) | |
else: | |
n = '旁白' | |
d = line['message'] | |
if d: | |
sc[name].append(n + ':' + d) | |
# ================= | |
for k, v in sc.items(): | |
if v: | |
with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f: | |
f.write('\n'.join(v)) | |
# ================= | |
import json | |
tmp = json.dumps(_n, ensure_ascii=False, indent=4) |