家族計画 ~追憶~
Browse files
v-corpus-zh/D.O/家族计画/追忆/0末莉.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:45cb089c6b312be8f293d8df5cad35b74c3d0b44fb9fe6cc524eb11edbf191bb
|
3 |
+
size 550391
|
v-corpus-zh/D.O/家族计画/追忆/1春花.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c82249328cec4276f7614c4e5120578d385e0321a2ea4954b4eea50e863d741f
|
3 |
+
size 260324
|
v-corpus-zh/D.O/家族计画/追忆/2准.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:79331002a1e81a2e61f72857ae405fd0b0458b201b38e3a8ee32d48d1ff117d3
|
3 |
+
size 107067
|
v-corpus-zh/D.O/家族计画/追忆/3青叶.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6e677b0e1bcdc3b477c09de65b7954be58c38d7a16bef76677d9abda0be58871
|
3 |
+
size 209001
|
v-corpus-zh/D.O/家族计画/追忆/4真纯.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8d78f1d5a71a6838c7b249e3f911ed7b9286a2fd9294ba5b69fdf7c6d73dd539
|
3 |
+
size 167239
|
v-corpus-zh/D.O/家族计画/追忆/luna_clean.re
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# \r\n「 → 「
|
2 |
+
# 「.+?」 → $0\r\n
|
3 |
+
# 』([^「『\r\n]{0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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.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 False
|
52 |
+
|
53 |
+
|
54 |
+
# =================
|
55 |
+
|
56 |
+
a = get_all_files_in_directory(r'E:\tmp\家族计划_\追忆', ext='.txt')
|
57 |
+
b = r'D:\datasets\tmp'
|
58 |
+
|
59 |
+
# =================
|
60 |
+
|
61 |
+
sc = {}
|
62 |
+
|
63 |
+
_n = {
|
64 |
+
"少女": "少女",
|
65 |
+
"司": "司",
|
66 |
+
"刘": "刘",
|
67 |
+
"?": "?",
|
68 |
+
"春花": "春花",
|
69 |
+
"乌鸦": "乌鸦",
|
70 |
+
"宽": "宽",
|
71 |
+
"男子": "男子",
|
72 |
+
"客人": "客人",
|
73 |
+
"青叶": "青叶",
|
74 |
+
"少年": "少年",
|
75 |
+
"准": "准",
|
76 |
+
"末莉": "末莉",
|
77 |
+
"房东": "房东",
|
78 |
+
"真纯": "真纯",
|
79 |
+
"金": "金",
|
80 |
+
"全体": "全体",
|
81 |
+
"威尔康": "威尔康",
|
82 |
+
"地主": "地主",
|
83 |
+
"店员": "店员",
|
84 |
+
"女子": "女子",
|
85 |
+
"景": "景",
|
86 |
+
"小夜": "小夜",
|
87 |
+
"面试官": "面试官",
|
88 |
+
"老爹": "老爹",
|
89 |
+
"乔迪": "乔迪",
|
90 |
+
"宽A": "宽A",
|
91 |
+
"宽B": "宽B",
|
92 |
+
"电视": "电视",
|
93 |
+
"父亲": "父亲",
|
94 |
+
"打工者": "打工者",
|
95 |
+
"男子1": "男子1",
|
96 |
+
"男子2": "男子2",
|
97 |
+
"男子3": "男子3",
|
98 |
+
"Jackie": "Jackie",
|
99 |
+
"Sarah": "Sarah",
|
100 |
+
"枫": "枫",
|
101 |
+
"伊佐坂": "伊佐坂",
|
102 |
+
"大场": "大场",
|
103 |
+
"业者": "业者",
|
104 |
+
"由利": "由利",
|
105 |
+
"顺子": "顺子",
|
106 |
+
"路人B": "路人B",
|
107 |
+
"路人A": "路人A",
|
108 |
+
"老人": "老人",
|
109 |
+
"园长": "园长",
|
110 |
+
"小孩": "小孩",
|
111 |
+
"女职员": "女职员",
|
112 |
+
"播音员": "播音员",
|
113 |
+
"添田": "添田",
|
114 |
+
"对手": "对手",
|
115 |
+
"部下": "部下",
|
116 |
+
"男孩": "男孩",
|
117 |
+
"全员": "全员",
|
118 |
+
"三人": "三人",
|
119 |
+
"邮递员": "邮递员",
|
120 |
+
"女子A": "女子A",
|
121 |
+
"女子B": "女子B",
|
122 |
+
"女子C": "女子C",
|
123 |
+
"女子高中生1": "女子高中生1",
|
124 |
+
"女子高中生2": "女子高中生2",
|
125 |
+
"狗": "狗",
|
126 |
+
"Meat": "Meat",
|
127 |
+
"主妇A": "主妇A",
|
128 |
+
"主妇B": "主妇B",
|
129 |
+
"主妇C": "主妇C",
|
130 |
+
"司机": "司机",
|
131 |
+
"事务员": "事务员",
|
132 |
+
"兰霞": "兰霞",
|
133 |
+
"Hasta Luego": "Hasta Luego",
|
134 |
+
"米莎": "米莎",
|
135 |
+
"若叶": "若叶",
|
136 |
+
"店长": "店长",
|
137 |
+
"声音": "声音",
|
138 |
+
"从厨房传来的声音": "从厨房传来的声音",
|
139 |
+
"叶": "叶",
|
140 |
+
}
|
141 |
+
|
142 |
+
_n_list = sorted(_n.keys(), key=len, reverse=True)
|
143 |
+
|
144 |
+
# =================
|
145 |
+
for path in a:
|
146 |
+
name = path[path.rindex('\\'):]
|
147 |
+
name = name[:-4]
|
148 |
+
if name not in sc:
|
149 |
+
sc[name] = []
|
150 |
+
print(name)
|
151 |
+
# =================
|
152 |
+
with open(path, 'r', encoding='utf-8') as f:
|
153 |
+
data = list(filter(lambda x: x,
|
154 |
+
(x.strip() for x in f.readlines())))
|
155 |
+
|
156 |
+
w_i = -1
|
157 |
+
while w_i < len(data) - 1:
|
158 |
+
w_i += 1
|
159 |
+
line: str = data[w_i]
|
160 |
+
# =================
|
161 |
+
|
162 |
+
if startsWithAny(line, {'「', '『'}):
|
163 |
+
sc[name].append('旁白:' + clearT(line))
|
164 |
+
continue
|
165 |
+
|
166 |
+
# n = ''
|
167 |
+
# if '「' in line:
|
168 |
+
# n = line[:line.index('「')]
|
169 |
+
# elif '『' in line:
|
170 |
+
# n = line[:line.index('『')]
|
171 |
+
#
|
172 |
+
# if not n or len(n) > 10:
|
173 |
+
# continue
|
174 |
+
#
|
175 |
+
# if n in _n:
|
176 |
+
# _n[n] = _n[n] + 1
|
177 |
+
#
|
178 |
+
# else:
|
179 |
+
# _n[n] = 1
|
180 |
+
# print(line)
|
181 |
+
|
182 |
+
if '「' in line:
|
183 |
+
n = line[:line.index('「')]
|
184 |
+
elif '『' in line:
|
185 |
+
n = line[:line.index('『')]
|
186 |
+
else:
|
187 |
+
if line.endswith('」'):
|
188 |
+
n = line[:line.rindex('「')]
|
189 |
+
elif line.endswith('』'):
|
190 |
+
n = line[:line.rindex('『')]
|
191 |
+
else:
|
192 |
+
sc[name].append('旁白:' + clearT(line))
|
193 |
+
continue
|
194 |
+
|
195 |
+
if not n:
|
196 |
+
print(line)
|
197 |
+
raise '001'
|
198 |
+
|
199 |
+
if n in _n:
|
200 |
+
line = line[len(n):]
|
201 |
+
n = _n[n]
|
202 |
+
sc[name].append(n + ':' + clearT(line))
|
203 |
+
continue
|
204 |
+
|
205 |
+
tmp = endsWithAny(n, _n_list)
|
206 |
+
|
207 |
+
if tmp:
|
208 |
+
line = line[len(n):]
|
209 |
+
n = n[:-len(tmp)]
|
210 |
+
sc[name].append('旁白:' + clearT(n))
|
211 |
+
n = _n[tmp]
|
212 |
+
sc[name].append(n + ':' + clearT(line))
|
213 |
+
continue
|
214 |
+
|
215 |
+
print(line)
|
216 |
+
sc[name].append('旁白:' + clearT(line))
|
217 |
+
|
218 |
+
|
219 |
+
# =================
|
220 |
+
|
221 |
+
for k, v in sc.items():
|
222 |
+
if v:
|
223 |
+
with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f:
|
224 |
+
f.write('\n'.join(v))
|
225 |
+
|
226 |
+
# =================
|
227 |
+
# _n = {k:clearT(k) for k,v in _n.items() if v > 3}
|
228 |
+
|
229 |
+
import json
|
230 |
+
|
231 |
+
tmp = json.dumps(_n, ensure_ascii=False, indent=4)
|