Datasets:

Languages:
Chinese
Tags:
Not-For-All-Audiences
License:
Limour commited on
Commit
28fe1c1
·
verified ·
1 Parent(s): 82d7545

Upload 9 files

Browse files
v-corpus-zh/Lose/哥特妄想/1.txt.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4882b278d48b10ee86309c134652de72ae2172c4c22e48dda3c60b03b770e36
3
+ size 38450
v-corpus-zh/Lose/哥特妄想/2.txt.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7d24c5fac6f0c99cd11333f747d32449565ab7890f73230523ec1ece0040f7c3
3
+ size 37411
v-corpus-zh/Lose/哥特妄想/3.txt.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d8f353f0774f4cd9094fd665db7ef5fb9d5dfadc909f988f47888325851e0b3
3
+ size 37465
v-corpus-zh/Lose/哥特妄想/4.txt.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6bc8deb1d9dd1f4c177437c8125c890680148de5debf4d5283ed4e35649292de
3
+ size 54117
v-corpus-zh/Lose/哥特妄想/5.txt.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb296182b737b9d064850c6ed2c0c62a153f665350110fdcdfc450e38087f26a
3
+ size 63227
v-corpus-zh/Lose/哥特妄想/H.txt.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:838c099393a28ef8e76b882a3f5373177d66d95f4f9e2d9605b98e14d06154c5
3
+ size 124645
v-corpus-zh/Lose/哥特妄想/e.txt.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:67378da13e82b6073396b98374c6ae73911a91a1a51274c79ad459975c136f1a
3
+ size 11106
v-corpus-zh/Lose/哥特妄想/o.txt.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08af8a4cb5cd96abab9e0b1e61f8a6de67be8e8f80ec2af7f96cbb0b17c017b6
3
+ size 9902
v-corpus-zh/Lose/哥特妄想/哥特妄想_ks.py ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 startsWithAlnum(s: str, _l = False):
47
+ retn = ''
48
+ for char in s:
49
+ if char.isalnum() or (_l and char == '_'):
50
+ retn += char
51
+ else:
52
+ break
53
+ return retn
54
+
55
+
56
+ def startsWithCmd(s: str):
57
+ cmd = startsWithAlnum(s, _l=True)
58
+ if cmd:
59
+ return s.startswith(cmd + ' ')
60
+ else:
61
+ return False
62
+
63
+
64
+ import re
65
+ reg_removeWait = re.compile(r'\[.+?]')
66
+
67
+
68
+ def removeWait(line):
69
+ tmp = reg_removeWait.sub('', line)
70
+ if tmp:
71
+ return tmp
72
+ else:
73
+ return line
74
+ # =================
75
+
76
+ a = get_all_files_in_directory(r'E:\tmp\哥特妄想\ks', ext='.ks')
77
+ b = r'D:\datasets\tmp'
78
+
79
+ # =================
80
+
81
+ sc = {}
82
+
83
+ _n = {
84
+ "貴路": "贵路",
85
+ "ロー": "ロー",
86
+ "警官": "警官",
87
+ "絶火": "绝火",
88
+ "塞門": "塞门",
89
+ "スミス": "史密斯",
90
+ "麗華": "丽华",
91
+ "いつき": "丽华",
92
+ "日木実": "日木实",
93
+ "絃人": "弦人",
94
+ "芦満": "芦満",
95
+ "やすな": "安奈",
96
+ "八宵": "八宵",
97
+ "生徒全員": "全体学生",
98
+ "吹摘": "吹摘",
99
+ "くずは": "葛叶", # 阿倍野静奈
100
+ "根本": "根本",
101
+ "剋弥": "克弥",
102
+ "レイミア/???": "?/蕾米娅",
103
+ "貴路子供": "贵路小时候",
104
+ "teacher": "老师",
105
+ "女性": "女性",
106
+ "レイミア": "蕾米娅",
107
+ "伯爵": "伯爵",
108
+ "ティーチャー": "老师",
109
+ "ヴァンダイン": "伯爵"
110
+ }
111
+
112
+ # =================
113
+
114
+
115
+ def tmp_filer(x):
116
+ return not ((x and x.isascii())
117
+ or startsWithAny(x, ('@','[if]'))
118
+ or (x.startswith('[') and x.endswith(']') and ' ' in x))
119
+ # =================
120
+
121
+
122
+ for path in a:
123
+ name = path[path.rindex('\\'):]
124
+ name = name[:2]
125
+ if name not in sc:
126
+ sc[name] = []
127
+ print(name)
128
+ # =================
129
+
130
+ with open(path, 'r', encoding='utf-16-le') as f:
131
+ print(next(f)) # BOM
132
+ data = list(filter(lambda x: not x.startswith(';'), (x.strip() for x in f.readlines())))
133
+
134
+ data = list(removeWait(x) for x in filter(tmp_filer, data))
135
+ d_s = False
136
+ for i, line in enumerate(data):
137
+ if not line:
138
+ d_s = False
139
+ continue
140
+ n = line.startswith('【') + line.endswith('】')
141
+ if n == 2:
142
+ n = line[1:len(line)-1]
143
+ if n in _n:
144
+ n = _n[n]
145
+ else:
146
+ _n[n] = clearT(n)
147
+ print(line, n)
148
+ nn = n
149
+ d_s = True
150
+ continue
151
+ elif n == 1:
152
+ n = line.strip('【】')
153
+ assert n in _n
154
+ nn = n
155
+ d_s = True
156
+ continue
157
+ else:
158
+ if line.startswith('「'):
159
+ d_s = True
160
+ d = line
161
+ if d_s:
162
+ nnn = nn
163
+ else:
164
+ nnn = '旁白'
165
+ d = clearT(d)
166
+ if d:
167
+ sc[name].append(nnn + ':' + d)
168
+ if line.endswith('」'):
169
+ d_s = False
170
+
171
+
172
+ # =================
173
+
174
+ for k, v in sc.items():
175
+ with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f:
176
+ f.write('\n'.join(v))
177
+ # =================
178
+ import json
179
+
180
+ tmp = json.dumps(_n, ensure_ascii=False, indent=2)