Upload 15 files
Browse files- v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenarioAs.txt.gz +3 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenarioFD.txt.gz +3 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenarioHa.txt.gz +3 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenariobo.txt.gz +3 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenariobu.txt.gz +3 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenarioko.txt.gz +3 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenariota.txt.gz +3 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/外传/海市蜃楼之馆外传_ks.py +320 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/本体/bad.txt.gz +3 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/本体/mem.txt.gz +3 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/本体/oma.txt.gz +3 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/本体/pro.txt.gz +3 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/本体/sce.txt.gz +3 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/本体/sea.txt.gz +3 -0
- v-corpus-zh/Novectacle/海市蜃楼之馆/本体/海市蜃楼之馆_ks.py +273 -0
v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenarioAs.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:627ff2ce0ab8baf47dd338fd5682997a9dcb0fd3b5674e3d2d26e6e66768e8c0
|
3 |
+
size 37556
|
v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenarioFD.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:472714c79ad082e31e9ba314aaf1f684814defc295fbbc3588191370c13fca07
|
3 |
+
size 260156
|
v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenarioHa.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:42d412369ac9c8fef4ca8162b7813ead5c31cdb928f1e50f3dcbee98d837251a
|
3 |
+
size 19142
|
v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenariobo.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e407a189d993df114dcd7aa73660022a88d0e88278d683f47981899fe6d4cb2d
|
3 |
+
size 5266
|
v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenariobu.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:efc795e9d2b74b31809f5f47eb5b5f0784963b90954008e7cae548e8dbf2920c
|
3 |
+
size 35309
|
v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenarioko.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7c194e7c1875a48469d1deb69039258a0db8ca3cee5105ee30952d4f10e4fb61
|
3 |
+
size 13240
|
v-corpus-zh/Novectacle/海市蜃楼之馆/外传/scenariota.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cec5f1bc661f1524c4b8ba1fc170a5de2c70ecf15f147bea721304f4ca7ec234
|
3 |
+
size 20310
|
v-corpus-zh/Novectacle/海市蜃楼之馆/外传/海市蜃楼之馆外传_ks.py
ADDED
@@ -0,0 +1,320 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.lstrip('n').strip().strip(r'\n').replace('\n', '\\n')
|
31 |
+
|
32 |
+
return _clearT
|
33 |
+
|
34 |
+
|
35 |
+
clearT = clearT()
|
36 |
+
|
37 |
+
|
38 |
+
def startsWithAny(s: str, keys):
|
39 |
+
for x in keys:
|
40 |
+
if s.startswith(x):
|
41 |
+
return x
|
42 |
+
else:
|
43 |
+
return False
|
44 |
+
|
45 |
+
|
46 |
+
def endsWithAny(s: str, keys):
|
47 |
+
for x in keys:
|
48 |
+
if s.endswith(x):
|
49 |
+
return x
|
50 |
+
else:
|
51 |
+
return ''
|
52 |
+
|
53 |
+
|
54 |
+
def listEndsWithAny(lines: list[str], keys, _remove=True):
|
55 |
+
retn = []
|
56 |
+
for line in lines:
|
57 |
+
tmp = endsWithAny(line, keys)
|
58 |
+
if tmp:
|
59 |
+
if _remove:
|
60 |
+
if len(tmp) < len(line):
|
61 |
+
retn.append(line[:-len(tmp)])
|
62 |
+
else:
|
63 |
+
break
|
64 |
+
else:
|
65 |
+
retn.append(line)
|
66 |
+
break
|
67 |
+
else:
|
68 |
+
retn.append(line)
|
69 |
+
return retn
|
70 |
+
|
71 |
+
|
72 |
+
def listRfind_idx(_i, _data, _condition):
|
73 |
+
for j in range(_i - 1, -1, -1):
|
74 |
+
if _condition(_data[j]):
|
75 |
+
return j
|
76 |
+
return _i
|
77 |
+
|
78 |
+
|
79 |
+
def listRfind(_i, _data, _condition, _filter, delta=1):
|
80 |
+
return list(filter(_filter, _data[listRfind_idx(_i, _data, _condition) + delta:_i + 1]))
|
81 |
+
|
82 |
+
|
83 |
+
def startsWithAlnum(s: str):
|
84 |
+
retn = ''
|
85 |
+
for char in s:
|
86 |
+
if char.isalnum():
|
87 |
+
retn += char
|
88 |
+
else:
|
89 |
+
break
|
90 |
+
return retn
|
91 |
+
|
92 |
+
|
93 |
+
# =================
|
94 |
+
|
95 |
+
a = get_all_files_in_directory(r'E:\tmp\海市蜃楼之馆\1\scenario', ext='.ks')
|
96 |
+
b = r'D:\datasets\tmp'
|
97 |
+
|
98 |
+
# =================
|
99 |
+
|
100 |
+
sc = {}
|
101 |
+
|
102 |
+
_n = {
|
103 |
+
"[jinobun]": "旁白",
|
104 |
+
"[maid]": "maid",
|
105 |
+
"[whitehair]": "whitehair",
|
106 |
+
"[unknown]": "?",
|
107 |
+
"[michel]": "michel",
|
108 |
+
"[extra]": "extra",
|
109 |
+
"[morgana]": "morgana",
|
110 |
+
"[giselle]": "giselle",
|
111 |
+
"[morgananormal]": "morgananormal",
|
112 |
+
"[mell]": "mell",
|
113 |
+
"[toyo]": "toyo",
|
114 |
+
"[jacopo]": "jacopo",
|
115 |
+
"[nellie]": "nellie",
|
116 |
+
"[pauline]": "pauline",
|
117 |
+
"[maria]": "maria",
|
118 |
+
"[7michel]": "michel",
|
119 |
+
"[7morgana]": "morgana",
|
120 |
+
"[7aimee]": "aimee",
|
121 |
+
"[georges]": "georges",
|
122 |
+
"[didier]": "didier",
|
123 |
+
"[picture]": "picture",
|
124 |
+
"[bestea]": "bestea",
|
125 |
+
"[man]": "man",
|
126 |
+
"[pmother]": "pmother",
|
127 |
+
"[creature]": "creature",
|
128 |
+
"[habi]": "habi",
|
129 |
+
"[habimother]": "habimother",
|
130 |
+
"[habifather]": "habifather",
|
131 |
+
"[pfather]": "pfather",
|
132 |
+
"[yukimasa]": "yukimasa",
|
133 |
+
"[funanori]": "funanori",
|
134 |
+
"[soul]": "soul",
|
135 |
+
"[friend1]": "friend1",
|
136 |
+
"[friend2]": "friend2",
|
137 |
+
"[3rd_maid]": "3rd_maid",
|
138 |
+
"[tomaso]": "[tomaso]",
|
139 |
+
"[mariagirl]": "mariagirl",
|
140 |
+
"[jacopoboy]": "jacopoboy",
|
141 |
+
"[jfather]": "jfather",
|
142 |
+
"[gyosya]": "gyosya",
|
143 |
+
"[monolog]": "monolog",
|
144 |
+
"[s_michel][hr]": "michel",
|
145 |
+
"[s_whitehair][hr]": "whitehair",
|
146 |
+
"[voice]": "voice",
|
147 |
+
"[otherman]": "otherman",
|
148 |
+
"[antonin]": "antonin",
|
149 |
+
"[lydie]": "lydie",
|
150 |
+
"[amedee]": "amedee",
|
151 |
+
"[child]": "child",
|
152 |
+
"[child2]": "child2",
|
153 |
+
"[villager]": "villager",
|
154 |
+
"[villager2]": "villager2",
|
155 |
+
"[villager3]": "villager3",
|
156 |
+
"[backlay]": "backlay",
|
157 |
+
"[knight]": "knight",
|
158 |
+
"[hayden]": "hayden",
|
159 |
+
"[michelle]": "michelle",
|
160 |
+
"[7jinobun]": "jinobun",
|
161 |
+
"[7antonin]": "antonin",
|
162 |
+
"[7lydie]": "lydie",
|
163 |
+
"[7michelle]": "michelle",
|
164 |
+
"[7didier]": "didier",
|
165 |
+
"[7georges]": "georges",
|
166 |
+
"[7man]": "man",
|
167 |
+
"[7menial]": "menial",
|
168 |
+
"[7abigail]": "abigail",
|
169 |
+
"[7abigail2]": "abigail",
|
170 |
+
"[7unknown]": "unknown",
|
171 |
+
"[7monolog]": "monolog",
|
172 |
+
"[priest]": "priest",
|
173 |
+
"[voice2]": "voice2",
|
174 |
+
"[voice3]": "voice3",
|
175 |
+
"[girl]": "girl",
|
176 |
+
"[sister]": "sister",
|
177 |
+
"[unknown2]": "unknown2",
|
178 |
+
"[8michel]": "michel",
|
179 |
+
"[8giselle]": "giselle",
|
180 |
+
"[lord]": "lord",
|
181 |
+
"[woman]": "woman",
|
182 |
+
"[slaver]": "slaver",
|
183 |
+
"[me]": "me",
|
184 |
+
"[mymother]": "mymother",
|
185 |
+
"[mell2]": "mell",
|
186 |
+
"[boy]": "boy",
|
187 |
+
"[nellie2]": "nellie",
|
188 |
+
"[yukimasa2]": "yukimasa",
|
189 |
+
"[pauline2]": "pauline2",
|
190 |
+
"[maria2]": "maria",
|
191 |
+
"[jacopo2]": "jacopo",
|
192 |
+
"[monolog_gray]": "monolog_gray",
|
193 |
+
"[beggar]": "beggar",
|
194 |
+
"[jijo]": "jijo",
|
195 |
+
"[arthur]": "arthur",
|
196 |
+
"[nellievoice]": "nellievoice",
|
197 |
+
"[mellvoice]": "mellvoice",
|
198 |
+
"[imeon]": "imeon",
|
199 |
+
"[barnier]": "barnier",
|
200 |
+
"[noble]": "noble",
|
201 |
+
"[gratien2]": "gratien",
|
202 |
+
"[gratien]": "gratien",
|
203 |
+
"[soldier]": "soldier",
|
204 |
+
"[mihari]": "mihari",
|
205 |
+
"[mihari2]": "mihari",
|
206 |
+
"[soldier2]": "soldier",
|
207 |
+
"[paul]": "paul",
|
208 |
+
"[nicola]": "nicola",
|
209 |
+
"[teo]": "teo",
|
210 |
+
"[youngs]": "youngs",
|
211 |
+
"[youngs2]": "youngs",
|
212 |
+
"[cantina]": "cantina",
|
213 |
+
"[whore]": "whore",
|
214 |
+
"[nobles]": "noble",
|
215 |
+
"[nobles2]": "noble",
|
216 |
+
"[slave]": "slave",
|
217 |
+
"[granny]": "granny",
|
218 |
+
"[stopse]": "stopse",
|
219 |
+
"[ceren]": "ceren",
|
220 |
+
"[myvoice]": "myvoice",
|
221 |
+
"[bard]": "bard",
|
222 |
+
"[blackguard]": "blackguard",
|
223 |
+
"[blackguard2]": "blackguard",
|
224 |
+
"[blackguard3]": "blackguard",
|
225 |
+
"[whores]": "whores",
|
226 |
+
"[whores2]": "whores",
|
227 |
+
"[otherman2]": "otherman",
|
228 |
+
"[ginevra]": "ginevra",
|
229 |
+
"[odilon]": "odilon",
|
230 |
+
"[woman2]": "woman",
|
231 |
+
"[crowd]": "crowd",
|
232 |
+
"[dingo]": "dingo",
|
233 |
+
"[liege]": "liege",
|
234 |
+
"[drivel]": "drivel",
|
235 |
+
"[children]": "children",
|
236 |
+
"[aide]": "aide",
|
237 |
+
"[kako]": "kako",
|
238 |
+
"[folks]": "folks",
|
239 |
+
"[obachan]": "obachan",
|
240 |
+
"[all]": "all"
|
241 |
+
}
|
242 |
+
|
243 |
+
# _n = {k:_n[k] for k in sorted(_n.keys(), key=len, reverse=True)}
|
244 |
+
# =================
|
245 |
+
import re
|
246 |
+
|
247 |
+
|
248 |
+
def tmp_filer(x):
|
249 |
+
return not (x.startswith(';')
|
250 |
+
or (x.startswith('[') != x.isascii())
|
251 |
+
or x.startswith('[if')
|
252 |
+
or (x.startswith('[') and x.endswith(']') and ' ' in x))
|
253 |
+
|
254 |
+
|
255 |
+
reg_removeWait = re.compile(r'\[.+?]')
|
256 |
+
|
257 |
+
|
258 |
+
def removeWait(line):
|
259 |
+
tmp = reg_removeWait.sub('', line)
|
260 |
+
if tmp:
|
261 |
+
return tmp
|
262 |
+
else:
|
263 |
+
return line
|
264 |
+
|
265 |
+
|
266 |
+
# =================
|
267 |
+
for path in a:
|
268 |
+
name = path[path.rindex('\\'):]
|
269 |
+
name = name[:11]
|
270 |
+
if name not in sc:
|
271 |
+
sc[name] = []
|
272 |
+
print(name)
|
273 |
+
# =================
|
274 |
+
|
275 |
+
with open(path, 'r', encoding='utf-16-le') as f:
|
276 |
+
data = [x.rstrip() for x in f.readlines()]
|
277 |
+
|
278 |
+
data = list(removeWait(x) for x in filter(tmp_filer, data))
|
279 |
+
|
280 |
+
for i, line in enumerate(data):
|
281 |
+
if not line.endswith('[cm]'):
|
282 |
+
continue
|
283 |
+
tmp = listRfind(i, data, lambda x: (x.endswith('[cm]') or startsWithAny(x, _n.keys())), lambda x: x, delta=0)
|
284 |
+
if not tmp.pop().startswith('[cm]'):
|
285 |
+
tmp.append(line[:-4])
|
286 |
+
tmp = listEndsWithAny(tmp, ('[p]',))
|
287 |
+
if not tmp:
|
288 |
+
continue
|
289 |
+
|
290 |
+
n = tmp[0]
|
291 |
+
tmp = [x for x in tmp if not (x.startswith('[') and x.endswith(']'))]
|
292 |
+
|
293 |
+
if not tmp:
|
294 |
+
continue
|
295 |
+
|
296 |
+
if n == '[cm]':
|
297 |
+
if tmp[0].startswith('*'):
|
298 |
+
continue
|
299 |
+
n = '旁白'
|
300 |
+
else:
|
301 |
+
if n in _n:
|
302 |
+
n = _n[n]
|
303 |
+
else:
|
304 |
+
_n[n] = clearT(n)
|
305 |
+
print(tmp, n)
|
306 |
+
|
307 |
+
d = '\\n'.join(tmp)
|
308 |
+
d = clearT(d)
|
309 |
+
if d:
|
310 |
+
sc[name].append(n + ':' + d)
|
311 |
+
|
312 |
+
# =================
|
313 |
+
|
314 |
+
for k, v in sc.items():
|
315 |
+
with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f:
|
316 |
+
f.write('\n'.join(v))
|
317 |
+
# =================
|
318 |
+
import json
|
319 |
+
|
320 |
+
tmp = json.dumps(_n, ensure_ascii=False, indent=2)
|
v-corpus-zh/Novectacle/海市蜃楼之馆/本体/bad.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b1d19be558f9e74c8d516a0c9e8e82eae789139e169ac9de4f620707f00e7a47
|
3 |
+
size 7999
|
v-corpus-zh/Novectacle/海市蜃楼之馆/本体/mem.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8fc55f08c524e425f3a4532c9ead60bae274432e129f80dd52a858a08d0fd92b
|
3 |
+
size 1733
|
v-corpus-zh/Novectacle/海市蜃楼之馆/本体/oma.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6180467a6928bcca4494c55d858234c4dc5ba942782c3d6192ff254e9f115669
|
3 |
+
size 21286
|
v-corpus-zh/Novectacle/海市蜃楼之馆/本体/pro.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e1350584321a0c58d0111e1faf1883dcca0cb4bedad1a07116a75e3c5b30ff54
|
3 |
+
size 3289
|
v-corpus-zh/Novectacle/海市蜃楼之馆/本体/sce.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:89f90c72a09b295e461ba1a1c37a078a3273900b7c1d18f354dc2a10b27216a7
|
3 |
+
size 708168
|
v-corpus-zh/Novectacle/海市蜃楼之馆/本体/sea.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.lstrip('n').strip().strip(r'\n').replace('\n', '\\n')
|
31 |
+
|
32 |
+
return _clearT
|
33 |
+
|
34 |
+
|
35 |
+
clearT = clearT()
|
36 |
+
|
37 |
+
|
38 |
+
def startsWithAny(s: str, keys):
|
39 |
+
for x in keys:
|
40 |
+
if s.startswith(x):
|
41 |
+
return x
|
42 |
+
else:
|
43 |
+
return False
|
44 |
+
|
45 |
+
|
46 |
+
def endsWithAny(s: str, keys):
|
47 |
+
for x in keys:
|
48 |
+
if s.endswith(x):
|
49 |
+
return x
|
50 |
+
else:
|
51 |
+
return ''
|
52 |
+
|
53 |
+
|
54 |
+
def listEndsWithAny(lines: list[str], keys, _remove=True):
|
55 |
+
retn = []
|
56 |
+
for line in lines:
|
57 |
+
tmp = endsWithAny(line, keys)
|
58 |
+
if tmp:
|
59 |
+
if _remove:
|
60 |
+
if len(tmp) < len(line):
|
61 |
+
retn.append(line[:-len(tmp)])
|
62 |
+
else:
|
63 |
+
break
|
64 |
+
else:
|
65 |
+
retn.append(line)
|
66 |
+
break
|
67 |
+
else:
|
68 |
+
retn.append(line)
|
69 |
+
return retn
|
70 |
+
|
71 |
+
|
72 |
+
def listRfind_idx(_i, _data, _condition):
|
73 |
+
for j in range(_i-1, -1, -1):
|
74 |
+
if _condition(_data[j]):
|
75 |
+
return j
|
76 |
+
return _i
|
77 |
+
|
78 |
+
|
79 |
+
def listRfind(_i, _data, _condition, _filter, delta=1):
|
80 |
+
return list(filter(_filter, _data[listRfind_idx(_i, _data, _condition) + delta:_i + 1]))
|
81 |
+
|
82 |
+
|
83 |
+
def startsWithAlnum(s: str):
|
84 |
+
retn = ''
|
85 |
+
for char in s:
|
86 |
+
if char.isalnum():
|
87 |
+
retn += char
|
88 |
+
else:
|
89 |
+
break
|
90 |
+
return retn
|
91 |
+
|
92 |
+
# =================
|
93 |
+
|
94 |
+
a = get_all_files_in_directory(r'E:\tmp\海市蜃楼之馆\0\scenario', ext='.ks')
|
95 |
+
b = r'D:\datasets\tmp'
|
96 |
+
|
97 |
+
# =================
|
98 |
+
|
99 |
+
sc = {}
|
100 |
+
|
101 |
+
_n = {
|
102 |
+
"[jinobun]": "旁白",
|
103 |
+
"[maid]": "maid",
|
104 |
+
"[whitehair]": "whitehair",
|
105 |
+
"[unknown]": "?",
|
106 |
+
"[michel]": "michel",
|
107 |
+
"[extra]": "extra",
|
108 |
+
"[morgana]": "morgana",
|
109 |
+
"[giselle]": "giselle",
|
110 |
+
"[morgananormal]": "morgananormal",
|
111 |
+
"[mell]": "mell",
|
112 |
+
"[toyo]": "toyo",
|
113 |
+
"[jacopo]": "jacopo",
|
114 |
+
"[nellie]": "nellie",
|
115 |
+
"[pauline]": "pauline",
|
116 |
+
"[maria]": "maria",
|
117 |
+
"[7michel]": "michel",
|
118 |
+
"[7morgana]": "morgana",
|
119 |
+
"[7aimee]": "aimee",
|
120 |
+
"[georges]": "georges",
|
121 |
+
"[didier]": "didier",
|
122 |
+
"[picture]": "picture",
|
123 |
+
"[bestea]": "bestea",
|
124 |
+
"[man]": "man",
|
125 |
+
"[pmother]": "pmother",
|
126 |
+
"[creature]": "creature",
|
127 |
+
"[habi]": "habi",
|
128 |
+
"[habimother]": "habimother",
|
129 |
+
"[habifather]": "habifather",
|
130 |
+
"[pfather]": "pfather",
|
131 |
+
"[yukimasa]": "yukimasa",
|
132 |
+
"[funanori]": "funanori",
|
133 |
+
"[soul]": "soul",
|
134 |
+
"[friend1]": "friend1",
|
135 |
+
"[friend2]": "friend2",
|
136 |
+
"[3rd_maid]": "3rd_maid",
|
137 |
+
"[tomaso]": "[tomaso]",
|
138 |
+
"[mariagirl]": "mariagirl",
|
139 |
+
"[jacopoboy]": "jacopoboy",
|
140 |
+
"[jfather]": "jfather",
|
141 |
+
"[gyosya]": "gyosya",
|
142 |
+
"[monolog]": "monolog",
|
143 |
+
"[s_michel][hr]": "michel",
|
144 |
+
"[s_whitehair][hr]": "whitehair",
|
145 |
+
"[voice]": "voice",
|
146 |
+
"[otherman]": "otherman",
|
147 |
+
"[antonin]": "antonin",
|
148 |
+
"[lydie]": "lydie",
|
149 |
+
"[amedee]": "amedee",
|
150 |
+
"[child]": "child",
|
151 |
+
"[child2]": "child2",
|
152 |
+
"[villager]": "villager",
|
153 |
+
"[villager2]": "villager2",
|
154 |
+
"[villager3]": "villager3",
|
155 |
+
"[backlay]": "backlay",
|
156 |
+
"[knight]": "knight",
|
157 |
+
"[hayden]": "hayden",
|
158 |
+
"[michelle]": "michelle",
|
159 |
+
"[7jinobun]": "jinobun",
|
160 |
+
"[7antonin]": "antonin",
|
161 |
+
"[7lydie]": "lydie",
|
162 |
+
"[7michelle]": "michelle",
|
163 |
+
"[7didier]": "didier",
|
164 |
+
"[7georges]": "georges",
|
165 |
+
"[7man]": "man",
|
166 |
+
"[7menial]": "menial",
|
167 |
+
"[7abigail]": "abigail",
|
168 |
+
"[7abigail2]": "abigail",
|
169 |
+
"[7unknown]": "unknown",
|
170 |
+
"[7monolog]": "monolog",
|
171 |
+
"[priest]": "priest",
|
172 |
+
"[voice2]": "voice2",
|
173 |
+
"[voice3]": "voice3",
|
174 |
+
"[girl]": "girl",
|
175 |
+
"[sister]": "sister",
|
176 |
+
"[unknown2]": "unknown2",
|
177 |
+
"[8michel]": "michel",
|
178 |
+
"[8giselle]": "giselle",
|
179 |
+
"[lord]": "lord",
|
180 |
+
"[woman]": "woman",
|
181 |
+
"[slaver]": "slaver",
|
182 |
+
"[me]": "me",
|
183 |
+
"[mymother]": "mymother",
|
184 |
+
"[mell2]": "mell",
|
185 |
+
"[boy]": "boy",
|
186 |
+
"[nellie2]": "nellie",
|
187 |
+
"[yukimasa2]": "yukimasa",
|
188 |
+
"[pauline2]": "pauline2",
|
189 |
+
"[maria2]": "maria",
|
190 |
+
"[jacopo2]": "jacopo",
|
191 |
+
"[monolog_gray]": "monolog_gray",
|
192 |
+
"[beggar]": "beggar",
|
193 |
+
"[jijo]": "jijo",
|
194 |
+
"[arthur]": "arthur",
|
195 |
+
"[nellievoice]": "nellievoice",
|
196 |
+
"[mellvoice]": "mellvoice"
|
197 |
+
}
|
198 |
+
|
199 |
+
_n = {k:_n[k] for k in sorted(_n.keys(), key=len, reverse=True)}
|
200 |
+
# =================
|
201 |
+
import re
|
202 |
+
|
203 |
+
|
204 |
+
def tmp_filer(x):
|
205 |
+
return not (x.startswith(';')
|
206 |
+
or (x.startswith('[') != x.isascii())
|
207 |
+
or x.startswith('[if')
|
208 |
+
or (x.startswith('[') and x.endswith(']') and ' ' in x))
|
209 |
+
|
210 |
+
|
211 |
+
reg_removeWait = re.compile(r'\[.+?]')
|
212 |
+
|
213 |
+
|
214 |
+
def removeWait(line):
|
215 |
+
tmp = reg_removeWait.sub('', line)
|
216 |
+
if tmp:
|
217 |
+
return tmp
|
218 |
+
else:
|
219 |
+
return line
|
220 |
+
|
221 |
+
# =================
|
222 |
+
for path in a:
|
223 |
+
name = path[path.rindex('\\'):]
|
224 |
+
name = name[:4]
|
225 |
+
if name not in sc:
|
226 |
+
sc[name] = []
|
227 |
+
print(name)
|
228 |
+
# =================
|
229 |
+
|
230 |
+
with open(path, 'r', encoding='utf-16-le') as f:
|
231 |
+
data = [x.rstrip() for x in f.readlines()]
|
232 |
+
|
233 |
+
data = list(removeWait(x) for x in filter(tmp_filer, data) if x)
|
234 |
+
|
235 |
+
for i, line in enumerate(data):
|
236 |
+
if not line.endswith('[cm]'):
|
237 |
+
continue
|
238 |
+
tmp = listRfind(i, data, lambda x: (x.endswith('[cm]') or startsWithAny(x, _n.keys())), lambda x: x, delta = 0)
|
239 |
+
if not tmp.pop().startswith('[cm]'):
|
240 |
+
tmp.append(line[:-4])
|
241 |
+
tmp = listEndsWithAny(tmp, ('[p]',))
|
242 |
+
if not tmp:
|
243 |
+
continue
|
244 |
+
|
245 |
+
n = tmp[0]
|
246 |
+
tmp = [x for x in tmp if not(x.startswith('[') and x.endswith(']'))]
|
247 |
+
|
248 |
+
if not tmp:
|
249 |
+
continue
|
250 |
+
|
251 |
+
if n == '[cm]':
|
252 |
+
if tmp[0].startswith('*'):
|
253 |
+
continue
|
254 |
+
n = '旁白'
|
255 |
+
else:
|
256 |
+
if n in _n:
|
257 |
+
n = _n[n]
|
258 |
+
else:
|
259 |
+
_n[n] = clearT(n)
|
260 |
+
print(tmp, n)
|
261 |
+
|
262 |
+
d = '\\n'.join(tmp)
|
263 |
+
d = clearT(d)
|
264 |
+
if d:
|
265 |
+
sc[name].append(n + ':' + d)
|
266 |
+
# =================
|
267 |
+
|
268 |
+
for k, v in sc.items():
|
269 |
+
with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f:
|
270 |
+
f.write('\n'.join(v))
|
271 |
+
# =================
|
272 |
+
import json
|
273 |
+
tmp = json.dumps(_n, ensure_ascii=False, indent=2)
|