Upload 2 files
Browse files
v-corpus-zh/KeroQ/美好的每一天 ~不连续存在~/1.txt.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:619d49c4bdfacb2e78817b884300b0909d0083d86cea6ca9158a60b14b6d2d32
|
3 |
+
size 1142124
|
v-corpus-zh/KeroQ/美好的每一天 ~不连续存在~/素晴日_ns.py
ADDED
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, _chrs):
|
47 |
+
retn = ''
|
48 |
+
for char in s:
|
49 |
+
if (char.isascii() and char.isalnum()) or (char in _chrs):
|
50 |
+
retn += char
|
51 |
+
else:
|
52 |
+
break
|
53 |
+
return retn
|
54 |
+
|
55 |
+
|
56 |
+
def listRfind_idx(_i, _data, _condition, delta=1):
|
57 |
+
for j in range(_i - 1, -1, -1):
|
58 |
+
if _condition(_data[j]):
|
59 |
+
return range(j+delta, _i+1)
|
60 |
+
return range(0, _i+1)
|
61 |
+
|
62 |
+
|
63 |
+
def startsWithCmd(s: str, _chrs=None):
|
64 |
+
if _chrs is None:
|
65 |
+
_chrs = {'_', '@'}
|
66 |
+
cmd = startsWithAlnum(s, _chrs)
|
67 |
+
if cmd:
|
68 |
+
return s.startswith(cmd + ' ')
|
69 |
+
else:
|
70 |
+
return False
|
71 |
+
# =================
|
72 |
+
|
73 |
+
a = get_all_files_in_directory(r'E:\tmp\素晴日', ext='.txt')
|
74 |
+
b = r'D:\datasets\tmp'
|
75 |
+
|
76 |
+
# =================
|
77 |
+
|
78 |
+
sc = {}
|
79 |
+
|
80 |
+
_n = {
|
81 |
+
"由岐": "由岐",
|
82 |
+
"卓司": "卓司",
|
83 |
+
"司": "司",
|
84 |
+
"镜": "镜",
|
85 |
+
"柘榴": "柘榴",
|
86 |
+
"镜·司": "镜&司",
|
87 |
+
"柘榴·镜": "柘榴&镜",
|
88 |
+
"司?柘榴": "司&柘榴",
|
89 |
+
"一同": "一同",
|
90 |
+
"美羽": "美羽",
|
91 |
+
"彩名": "彩名",
|
92 |
+
"布偶": "布偶",
|
93 |
+
"陌客": "陌客",
|
94 |
+
"本": "本",
|
95 |
+
"槝劶尷奒": "大叔",
|
96 |
+
"女子校生": "同校女生",
|
97 |
+
"男子校生": "同校男生",
|
98 |
+
"清川": "清川",
|
99 |
+
"瀕名川": "濒名川",
|
100 |
+
"先生": "先生",
|
101 |
+
"男子学生": "男学生",
|
102 |
+
"男子": "男子",
|
103 |
+
"男子生徒": "男学生",
|
104 |
+
"洁": "洁",
|
105 |
+
"安子": "安子",
|
106 |
+
"颔田": "颔田",
|
107 |
+
"閭宫": "闾宫",
|
108 |
+
"羽咲": "羽咲",
|
109 |
+
"希实香": "希实香",
|
110 |
+
"潔": "洁",
|
111 |
+
"校内广播": "校内广播",
|
112 |
+
"大婶": "大婶",
|
113 |
+
"间宫": "间宫",
|
114 |
+
"皆守": "皆守",
|
115 |
+
"城山": "城山",
|
116 |
+
"沼田": "沼田",
|
117 |
+
"饭沼": "饭沼",
|
118 |
+
"西村": "西村",
|
119 |
+
"西山": "西山",
|
120 |
+
"莉露露": "莉露露",
|
121 |
+
"教師": "教师",
|
122 |
+
"机": "机",
|
123 |
+
"惠": "惠",
|
124 |
+
"聪子": "聪子",
|
125 |
+
"濑名川": "濑名川",
|
126 |
+
"饭田": "饭田",
|
127 |
+
"明日美": "明日美",
|
128 |
+
"信者": "信者",
|
129 |
+
"明日美父亲": "明日美父亲",
|
130 |
+
"明日美母亲": "明日美母亲",
|
131 |
+
"大妈": "大妈",
|
132 |
+
"男行人": "男行人",
|
133 |
+
"女行人": "女行人",
|
134 |
+
"公司职员": "公司职员",
|
135 |
+
"观众": "观众",
|
136 |
+
"神": "神",
|
137 |
+
" 希实香": "希实香",
|
138 |
+
"店长": "店长",
|
139 |
+
"店员": "店员",
|
140 |
+
"男店员": "男店员",
|
141 |
+
"男性教师": "男性教师",
|
142 |
+
"女性教师": "女性教师",
|
143 |
+
"中年男性教师": "中年男性教师",
|
144 |
+
"女子生徒": "女学生",
|
145 |
+
"教师": "教师",
|
146 |
+
"男学生": "男学生",
|
147 |
+
"女学生": "女学生",
|
148 |
+
"别的学校的学生": "别的学校的学生",
|
149 |
+
"不良们": "不良们",
|
150 |
+
"宇佐美": "宇佐美",
|
151 |
+
"亚由美": "亚由美",
|
152 |
+
"恶棍": "恶棍",
|
153 |
+
"Master": "Master",
|
154 |
+
"客A": "客A",
|
155 |
+
"客B": "客B",
|
156 |
+
"木村": "木村",
|
157 |
+
"老师": "老师",
|
158 |
+
"男生": "男生",
|
159 |
+
"女生": "女生",
|
160 |
+
"人妖": "人妖",
|
161 |
+
"客": "客",
|
162 |
+
"齐声": "齐声",
|
163 |
+
"浩夫": "浩夫",
|
164 |
+
"学员": "学员",
|
165 |
+
"练习生": "练习生",
|
166 |
+
"水上": "水上",
|
167 |
+
"琴美": "琴美",
|
168 |
+
"卓司?琴美": "卓司&琴美"
|
169 |
+
}
|
170 |
+
|
171 |
+
# =================
|
172 |
+
for path in a:
|
173 |
+
name = path[path.rindex('\\'):]
|
174 |
+
if name not in sc:
|
175 |
+
sc[name] = []
|
176 |
+
print(name)
|
177 |
+
# =================
|
178 |
+
|
179 |
+
with open(path, 'r', encoding='utf-8') as f:
|
180 |
+
data = list(filter(lambda x: (not x.startswith(';')) and
|
181 |
+
(x.endswith('\\') or x.endswith('/')),
|
182 |
+
(x.strip() for x in f.readlines())))
|
183 |
+
|
184 |
+
|
185 |
+
w_i = -1
|
186 |
+
while w_i < len(data) - 1:
|
187 |
+
w_i += 1
|
188 |
+
line = data[w_i]
|
189 |
+
if not line.endswith('\\'):
|
190 |
+
continue
|
191 |
+
idx = listRfind_idx(w_i, data,
|
192 |
+
lambda x: x.endswith('\\'), delta=1)
|
193 |
+
tmp = [data[j].strip('\\/') for j in idx if data[j]]
|
194 |
+
if tmp[0].startswith('['):
|
195 |
+
assert ']' in tmp[0]
|
196 |
+
idx = tmp[0].index(']')
|
197 |
+
n = tmp[0][1:idx]
|
198 |
+
tmp[0] = tmp[0][idx+1:]
|
199 |
+
if n in _n:
|
200 |
+
n = _n[n]
|
201 |
+
else:
|
202 |
+
_n[n] = clearT(n)
|
203 |
+
print(n, tmp)
|
204 |
+
else:
|
205 |
+
n = '旁白'
|
206 |
+
d = '\\n'.join(tmp)
|
207 |
+
d = clearT(d)
|
208 |
+
if d:
|
209 |
+
sc[name].append(n + ':' + d)
|
210 |
+
|
211 |
+
# =================
|
212 |
+
|
213 |
+
for k, v in sc.items():
|
214 |
+
with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f:
|
215 |
+
f.write('\n'.join(v))
|
216 |
+
|
217 |
+
# =================
|
218 |
+
import json
|
219 |
+
tmp = json.dumps(_n, ensure_ascii=False, indent=2)
|