糖调!-sugarfull tempering-
Browse files
v-corpus-zh/Recette/糖调!-sugarfull tempering-/0.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d84ba3d22460c8d52730731e20539658dc123c11f68ffe63bcead721dbabb850
|
3 |
+
size 436132
|
v-corpus-zh/Recette/糖调!-sugarfull tempering-/糖调_scn.py
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def get_all_files_in_directory(directory, ext=''):
|
2 |
+
import os
|
3 |
+
import re
|
4 |
+
custom_sort_key_re = re.compile('([0-9]+)')
|
5 |
+
|
6 |
+
def custom_sort_key(s):
|
7 |
+
# 将字符串中的数字部分转换为整数,然后进行排序
|
8 |
+
return [int(x) if x.isdigit() else x for x in custom_sort_key_re.split(s)]
|
9 |
+
|
10 |
+
all_files = []
|
11 |
+
for root, dirs, files in os.walk(directory):
|
12 |
+
for file in files:
|
13 |
+
if file.endswith(ext):
|
14 |
+
file_path = os.path.join(root, file)
|
15 |
+
all_files.append(file_path)
|
16 |
+
return sorted(all_files, key=custom_sort_key)
|
17 |
+
|
18 |
+
|
19 |
+
def clearT():
|
20 |
+
import unicodedata
|
21 |
+
from opencc import OpenCC
|
22 |
+
|
23 |
+
def full2half(input_str):
|
24 |
+
return ''.join([unicodedata.normalize('NFKC', char) for char in input_str])
|
25 |
+
|
26 |
+
cc = OpenCC('t2s') # 't2s'表示繁体转简体
|
27 |
+
|
28 |
+
def _clearT(s):
|
29 |
+
s = cc.convert(full2half(s))
|
30 |
+
return s.strip().replace('\n', '\\n')
|
31 |
+
|
32 |
+
return _clearT
|
33 |
+
|
34 |
+
|
35 |
+
clearT = clearT()
|
36 |
+
|
37 |
+
|
38 |
+
# =================
|
39 |
+
|
40 |
+
a = get_all_files_in_directory(r'E:\tmp\糖调_\scn', ext='.txt.json')
|
41 |
+
b = r'E:\tmp\糖调_\text'
|
42 |
+
|
43 |
+
# =================
|
44 |
+
|
45 |
+
# =================
|
46 |
+
|
47 |
+
sc = {}
|
48 |
+
|
49 |
+
_n = {
|
50 |
+
"華": "华",
|
51 |
+
"める": "芽瑠",
|
52 |
+
"氷織": "冰织",
|
53 |
+
"氷織、める": "冰织&芽瑠",
|
54 |
+
"": "旁白",
|
55 |
+
"クロウ": "九郎",
|
56 |
+
"小町": "小町",
|
57 |
+
"あいら": "爱良",
|
58 |
+
"村崎先生": "村崎先生",
|
59 |
+
"古倉店長": "古仓店长",
|
60 |
+
"ヤマダ": "紳士",
|
61 |
+
"おそのさん": "大叔",
|
62 |
+
"麦野": "麦野",
|
63 |
+
"マダム牛尾": "牛尾夫人",
|
64 |
+
"満素": "満素",
|
65 |
+
"八百屋ムラサキ": "村崎",
|
66 |
+
"ショコラ": "巧克拉",
|
67 |
+
"ガトー": "加特",
|
68 |
+
"きゃらめる": "犬",
|
69 |
+
"冰织、める": "冰织&芽瑠",
|
70 |
+
"朋友1": "朋友1",
|
71 |
+
"朋友2": "朋友2",
|
72 |
+
"朋友3": "朋友3",
|
73 |
+
"ハイランド": "高地",
|
74 |
+
"アイリッシュ": "爱尔兰",
|
75 |
+
"本居": "本居",
|
76 |
+
"ばなな": "香蕉",
|
77 |
+
"きなこ": "黄豆",
|
78 |
+
"どーなつ": "甜甜圈",
|
79 |
+
"しらたま": "白玉",
|
80 |
+
"すこんぶ": "水柱",
|
81 |
+
"ついとろーねんしゅにってん": "粘糊糊",
|
82 |
+
"子供1": "小孩子1",
|
83 |
+
"子供2": "小孩子2",
|
84 |
+
"冰织、ショコラ": "冰织&巧克拉",
|
85 |
+
"子供3": "小孩子3",
|
86 |
+
"子供们": "孩子们",
|
87 |
+
"满素": "满素",
|
88 |
+
"麦野さん": "麦野",
|
89 |
+
"氷織、芽瑠、ショコラ": "冰织&芽瑠&巧克拉",
|
90 |
+
"氷織父": "冰织父",
|
91 |
+
"氷織母": "冰织母",
|
92 |
+
"女の子1": "女子1",
|
93 |
+
"女の子2": "女子2",
|
94 |
+
"冰织·める": "冰织&芽瑠",
|
95 |
+
"幼女": "幼女",
|
96 |
+
"村崎医生": "村崎医生",
|
97 |
+
"氷雪": "冰雪",
|
98 |
+
"7匹": "七匹",
|
99 |
+
"める、ショコラ": "芽瑠&巧克拉",
|
100 |
+
"友達1": "朋友1",
|
101 |
+
"友達2": "朋友2",
|
102 |
+
"子供": "小孩子",
|
103 |
+
"母親": "母亲",
|
104 |
+
"お客さん": "客人",
|
105 |
+
"全員": "全员",
|
106 |
+
"冰织,芽瑠,ショコラ": "冰织&芽瑠&巧克拉",
|
107 |
+
"芽瑠,ショコラ": "芽瑠&巧克拉",
|
108 |
+
"烟囱掃除夫": "烟囱扫除夫",
|
109 |
+
"パルファン": "八扇",
|
110 |
+
"業者": "商人",
|
111 |
+
"氷織,める": "冰织&芽瑠"
|
112 |
+
}
|
113 |
+
|
114 |
+
# =================
|
115 |
+
import json
|
116 |
+
|
117 |
+
for path in a:
|
118 |
+
name = path[path.rindex('\\'):]
|
119 |
+
name = name[:2]
|
120 |
+
if name not in sc:
|
121 |
+
sc[name] = []
|
122 |
+
print(name)
|
123 |
+
# =================
|
124 |
+
|
125 |
+
with open(path, 'r', encoding='utf-8') as json_file:
|
126 |
+
data = json.load(json_file)
|
127 |
+
|
128 |
+
# =================
|
129 |
+
for texts in data['scenes']:
|
130 |
+
try:
|
131 |
+
for texts in texts['texts']:
|
132 |
+
# print(texts)
|
133 |
+
n = texts[0]
|
134 |
+
if n is None:
|
135 |
+
n = '旁白'
|
136 |
+
else:
|
137 |
+
if n in _n:
|
138 |
+
n = _n[n]
|
139 |
+
else:
|
140 |
+
_n[n] = clearT(n).replace('・', '&')
|
141 |
+
print(texts, n)
|
142 |
+
|
143 |
+
# =================
|
144 |
+
d = clearT(texts[2])
|
145 |
+
if d:
|
146 |
+
sc[name].append(n + ':' + d)
|
147 |
+
|
148 |
+
except KeyError:
|
149 |
+
if type(texts) is not dict:
|
150 |
+
print(texts)
|
151 |
+
|
152 |
+
# =================
|
153 |
+
|
154 |
+
for k, v in sc.items():
|
155 |
+
if v:
|
156 |
+
with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f:
|
157 |
+
f.write('\n'.join(v))
|
158 |
+
|
159 |
+
# =================
|
160 |
+
import json
|
161 |
+
tmp = json.dumps(_n, ensure_ascii=False, indent=4)
|