Upload 5 files
Browse files
v-corpus-zh/UGUISUKAGURA/水葬银币的伊斯特里亚/k.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8dc721fc370ab21c6351aff46c3b691e6e05405e85e5faab6a2cd02293c68243
|
3 |
+
size 52388
|
v-corpus-zh/UGUISUKAGURA/水葬银币的伊斯特里亚/m.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eb6efcd838c11dcd2e56b2d88e67ce95cab45378f3d9d643a6e5401d6e01246f
|
3 |
+
size 906113
|
v-corpus-zh/UGUISUKAGURA/水葬银币的伊斯特里亚/s.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:839309fa8aa99b17d41ef5bd68b15f8c182bc459c63cd89fc6da56e950617ad8
|
3 |
+
size 55036
|
v-corpus-zh/UGUISUKAGURA/水葬银币的伊斯特里亚/y.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:015c6f458ce1e749a251e636b2815e94fe49010fdc47e52100a6beea9838760d
|
3 |
+
size 104685
|
v-corpus-zh/UGUISUKAGURA/水葬银币的伊斯特里亚/水葬银货_ks.py
ADDED
@@ -0,0 +1,246 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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().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 startsWithAlnum(s: str, _chrs):
|
47 |
+
retn = ''
|
48 |
+
for char in s:
|
49 |
+
if (char.isalnum()) or (char in _chrs):
|
50 |
+
retn += char
|
51 |
+
else:
|
52 |
+
break
|
53 |
+
return retn
|
54 |
+
|
55 |
+
|
56 |
+
def startsWithCmd(s: str, _chrs=None):
|
57 |
+
if _chrs is None:
|
58 |
+
_chrs = {'_', '@'}
|
59 |
+
cmd = startsWithAlnum(s, _chrs)
|
60 |
+
if cmd:
|
61 |
+
return s.startswith(cmd + ' ')
|
62 |
+
else:
|
63 |
+
return False
|
64 |
+
|
65 |
+
|
66 |
+
import re
|
67 |
+
|
68 |
+
reg_removeWait = re.compile(r'\[.+?]')
|
69 |
+
|
70 |
+
|
71 |
+
def removeWait(_line):
|
72 |
+
_tmp = reg_removeWait.sub('', _line)
|
73 |
+
if _tmp:
|
74 |
+
return _tmp
|
75 |
+
else:
|
76 |
+
return _line
|
77 |
+
|
78 |
+
|
79 |
+
def getCmdArgs(_cmd):
|
80 |
+
_args = ['']
|
81 |
+
_i = -1
|
82 |
+
_inQuota = ''
|
83 |
+
while _i < len(_cmd) - 1:
|
84 |
+
_i += 1
|
85 |
+
char = _cmd[_i]
|
86 |
+
if _inQuota:
|
87 |
+
_args[-1] += char
|
88 |
+
if char == _inQuota:
|
89 |
+
_inQuota = ''
|
90 |
+
elif char == '\\':
|
91 |
+
_i += 1
|
92 |
+
char = _cmd[_i]
|
93 |
+
_args[-1] += char
|
94 |
+
else:
|
95 |
+
pass
|
96 |
+
else:
|
97 |
+
if char == ' ':
|
98 |
+
_args.append('')
|
99 |
+
while _i < len(_cmd) - 1:
|
100 |
+
_i += 1
|
101 |
+
char = _cmd[_i]
|
102 |
+
if char != ' ':
|
103 |
+
_i -= 1
|
104 |
+
break
|
105 |
+
continue
|
106 |
+
elif char in {'"', "'"}:
|
107 |
+
_inQuota = char
|
108 |
+
else:
|
109 |
+
pass
|
110 |
+
_args[-1] += char
|
111 |
+
continue
|
112 |
+
return _args
|
113 |
+
|
114 |
+
|
115 |
+
def args2map(_args):
|
116 |
+
retn = {}
|
117 |
+
for _i in range(1, len(_args)):
|
118 |
+
_arg = _args[_i]
|
119 |
+
if '=' not in _arg:
|
120 |
+
if '=' in _arg:
|
121 |
+
_arg = _arg.replace('=', '=')
|
122 |
+
else:
|
123 |
+
continue
|
124 |
+
_idx = _arg.index('=')
|
125 |
+
_k = _arg[:_idx]
|
126 |
+
if '"' in _k or "'" in _k:
|
127 |
+
continue
|
128 |
+
_v = _arg[_idx + 1:]
|
129 |
+
if _v.startswith('"') or _v.startswith("'"):
|
130 |
+
_v = _v[1:len(_v) - 1]
|
131 |
+
retn[_k] = _v
|
132 |
+
return retn
|
133 |
+
|
134 |
+
|
135 |
+
# =================
|
136 |
+
|
137 |
+
a = get_all_files_in_directory(r'E:\tmp\水葬银货\ks', ext='.ks')
|
138 |
+
b = r'D:\datasets\tmp'
|
139 |
+
|
140 |
+
# =================
|
141 |
+
|
142 |
+
|
143 |
+
sc = {}
|
144 |
+
|
145 |
+
_n = {
|
146 |
+
"英士": "英士",
|
147 |
+
"夕樱": "夕樱",
|
148 |
+
"逸美": "逸美",
|
149 |
+
"和奏": "和奏",
|
150 |
+
"祈吏": "祈吏",
|
151 |
+
"小夜": "小夜",
|
152 |
+
"学生A": "学生A",
|
153 |
+
"学生B": "学生B",
|
154 |
+
"学生C": "学生C",
|
155 |
+
"黑铁": "黑铁",
|
156 |
+
"小胁": "小胁",
|
157 |
+
"摇": "摇",
|
158 |
+
"宗名": "宗名",
|
159 |
+
"玖玖里": "玖玖里",
|
160 |
+
"红叶": "红叶",
|
161 |
+
"灯": "灯",
|
162 |
+
"男生": "男生",
|
163 |
+
"学生": "学生",
|
164 |
+
"紫子": "紫子",
|
165 |
+
"客人": "客人",
|
166 |
+
"C·A": "C·A",
|
167 |
+
"教师": "教师",
|
168 |
+
"和奏祖父": "和奏祖父",
|
169 |
+
"征士": "征士",
|
170 |
+
"姐姐": "姐姐",
|
171 |
+
"老人": "老人",
|
172 |
+
"紫乃": "紫乃",
|
173 |
+
"看護師": "护士",
|
174 |
+
"警備員": "警备员",
|
175 |
+
"客": "客",
|
176 |
+
"纯": "纯",
|
177 |
+
"SP": "SP",
|
178 |
+
"静琉": "静琉"
|
179 |
+
}
|
180 |
+
|
181 |
+
# =================
|
182 |
+
for path in a:
|
183 |
+
name = path[path.rindex('\\'):]
|
184 |
+
name = name[9:10]
|
185 |
+
if name.isdigit():
|
186 |
+
name = 'm'
|
187 |
+
if name not in sc:
|
188 |
+
sc[name] = []
|
189 |
+
print(name)
|
190 |
+
# =================
|
191 |
+
|
192 |
+
with open(path, 'r', encoding='utf-8') as f:
|
193 |
+
data = list(filter(lambda x: x and (not x.startswith(';')),
|
194 |
+
(x.rstrip() for x in f.readlines())))
|
195 |
+
|
196 |
+
# =================
|
197 |
+
w_i = -1
|
198 |
+
while w_i < len(data) - 1:
|
199 |
+
w_i += 1
|
200 |
+
line: str = data[w_i]
|
201 |
+
# =================
|
202 |
+
if line != '[cs]':
|
203 |
+
continue
|
204 |
+
# =================
|
205 |
+
tmp = []
|
206 |
+
n = '旁白'
|
207 |
+
while w_i < len(data) - 1:
|
208 |
+
w_i += 1
|
209 |
+
line: str = data[w_i]
|
210 |
+
if line == '[cs]':
|
211 |
+
w_i -= 1
|
212 |
+
break
|
213 |
+
if line.startswith('[') and line.endswith(']'):
|
214 |
+
if '[name ' in line:
|
215 |
+
line = line[line.index('[name'):]
|
216 |
+
line = line[1:line.index(']')]
|
217 |
+
args = args2map(getCmdArgs(line.strip('[]')))
|
218 |
+
n: str = args['fn']
|
219 |
+
if n in _n:
|
220 |
+
n = _n[n]
|
221 |
+
else:
|
222 |
+
_n[n] = clearT(n)
|
223 |
+
print(line)
|
224 |
+
else:
|
225 |
+
if line.startswith('*'):
|
226 |
+
continue
|
227 |
+
line = clearT(removeWait(line))
|
228 |
+
if line:
|
229 |
+
tmp.append(line)
|
230 |
+
if line.endswith('[ps]'):
|
231 |
+
break
|
232 |
+
line = '\\n'.join(tmp)
|
233 |
+
# =================
|
234 |
+
d = clearT(line)
|
235 |
+
if d:
|
236 |
+
sc[name].append(n + ':' + d)
|
237 |
+
# =================
|
238 |
+
|
239 |
+
for k, v in sc.items():
|
240 |
+
if v:
|
241 |
+
with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f:
|
242 |
+
f.write('\n'.join(v))
|
243 |
+
|
244 |
+
# =================
|
245 |
+
import json
|
246 |
+
tmp = json.dumps(_n, ensure_ascii=False, indent=4)
|