Upload 3 files
Browse files
v-corpus-zh/ωstar/万华镜/30/03.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:15e2cf026ab9f343d6c1588909ffd19e9a2c2821f8403134bc2ed033d87d8b4f
|
3 |
+
size 416265
|
v-corpus-zh/ωstar/万华镜/30/convertToUTF8.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#-*- encoding:utf-8 -*-
|
2 |
+
#
|
3 |
+
# Notepad++ Python script plugin script.
|
4 |
+
# For converting file encoding & lineending.
|
5 |
+
#
|
6 |
+
import os
|
7 |
+
import sys
|
8 |
+
|
9 |
+
filePathSrc = notepad.prompt("请输入目录路径".decode('utf-8').encode('gbk'), "输入目录路径".decode('utf-8').encode('gbk'))
|
10 |
+
filter_exts = [".txt"]
|
11 |
+
|
12 |
+
for root, dirs, files in os.walk(filePathSrc):
|
13 |
+
for fn in files:
|
14 |
+
print fn.decode('gbk').encode('utf-8')
|
15 |
+
file_name, file_ext = os.path.splitext(fn)
|
16 |
+
if file_ext in filter_exts:# Specify type of the files
|
17 |
+
notepad.open((root + "\\" + fn).decode('gbk').encode('utf-8'))
|
18 |
+
print notepad.menuCommand(MENUCOMMAND.FORMAT_CONV2_AS_UTF_8)
|
19 |
+
notepad.save()
|
20 |
+
notepad.close()
|
21 |
+
print 'finish'
|
v-corpus-zh/ωstar/万华镜/30/whj_03_nc.py
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
39 |
+
a = get_all_files_in_directory(r'E:\tmp\whj\3\ns\script', ext='.txt')
|
40 |
+
b = r'D:\datasets\tmp'
|
41 |
+
|
42 |
+
# =================
|
43 |
+
|
44 |
+
sc = {}
|
45 |
+
|
46 |
+
_n = {
|
47 |
+
"深见": "深见",
|
48 |
+
"女侍": "女侍",
|
49 |
+
"莲华": "莲华",
|
50 |
+
"龙之介": "龙之介",
|
51 |
+
"村中青年": "村中青年",
|
52 |
+
"神父": "神父",
|
53 |
+
"村民A": "村民A",
|
54 |
+
"村民B": "村民B",
|
55 |
+
"村民C": "村民C",
|
56 |
+
"狂犬": "狂犬",
|
57 |
+
"肌肉男": "肌肉男",
|
58 |
+
"莉莉": "莉莉",
|
59 |
+
"客人A": "客人A",
|
60 |
+
"客人B": "客人B",
|
61 |
+
"客人C": "客人C",
|
62 |
+
"盖亚": "盖亚",
|
63 |
+
"Mother": "Mother",
|
64 |
+
"亚璃子": "亚璃子",
|
65 |
+
"???": "?",
|
66 |
+
"托尼": "托尼",
|
67 |
+
"洛特": "洛特",
|
68 |
+
"道格": "道格",
|
69 |
+
"游魂者": "游魂者",
|
70 |
+
"灯露椎": "灯露椎",
|
71 |
+
"托托": "托托",
|
72 |
+
"怪物": "怪物",
|
73 |
+
"村民": "村民",
|
74 |
+
"僵尸": "僵尸",
|
75 |
+
"亚璃子,龙之介": "亚璃子&龙之介",
|
76 |
+
"孩子A": "孩子A",
|
77 |
+
"熊孩子B": "熊孩子B",
|
78 |
+
"被叫做魔女的女人": "被叫做魔女的女人",
|
79 |
+
"村民女": "村民女",
|
80 |
+
"客人": "客人",
|
81 |
+
"灯路椎": "灯路椎",
|
82 |
+
"孩子B": "孩子B",
|
83 |
+
"孩子C": "孩子C",
|
84 |
+
"孩子D": "孩子D",
|
85 |
+
"孩子E": "孩子E",
|
86 |
+
"孩子F": "孩子F",
|
87 |
+
"村民D": "村民D",
|
88 |
+
"妈妈": "妈妈",
|
89 |
+
"母亲": "母亲",
|
90 |
+
"女待": "女待"
|
91 |
+
}
|
92 |
+
# =================
|
93 |
+
import re
|
94 |
+
cselr = re.compile(r'(",\*)|(,")')
|
95 |
+
for path in a:
|
96 |
+
name = path[path.rindex('\\'):]
|
97 |
+
name = '03'
|
98 |
+
if name not in sc:
|
99 |
+
sc[name] = []
|
100 |
+
print(name)
|
101 |
+
# =================
|
102 |
+
|
103 |
+
with open(path, 'r', encoding='utf-8') as f:
|
104 |
+
data = f.readlines()
|
105 |
+
|
106 |
+
# =================
|
107 |
+
csel = {} # 分支选项
|
108 |
+
goto = set() # 懒得弄了
|
109 |
+
for line in data:
|
110 |
+
line = line.strip()
|
111 |
+
if line.startswith(';'):
|
112 |
+
if not line.isascii():
|
113 |
+
# print(line)
|
114 |
+
pass
|
115 |
+
continue
|
116 |
+
if line.startswith('chara'):
|
117 |
+
continue
|
118 |
+
if line.isascii():
|
119 |
+
if line.startswith('*k'):
|
120 |
+
line = line[1:]
|
121 |
+
if line in goto:
|
122 |
+
continue
|
123 |
+
assert line in csel
|
124 |
+
line = csel[line]
|
125 |
+
print(line)
|
126 |
+
elif line.startswith('goto '):
|
127 |
+
goto.add(line[6:])
|
128 |
+
else:
|
129 |
+
continue
|
130 |
+
if line.startswith('csel '):
|
131 |
+
line = line[5:]
|
132 |
+
line = cselr.split(line)
|
133 |
+
assert len(line) % 2 == 0
|
134 |
+
line = [x for x in line if (x is not None and x not in ('",*', ',"'))]
|
135 |
+
for i in range(0, len(line), 2):
|
136 |
+
csel[line[i+1]] = '选择:' + line[i].strip('"')
|
137 |
+
continue
|
138 |
+
tmp = line.split(']「')
|
139 |
+
if len(tmp) == 1:
|
140 |
+
if '] ' in tmp[0] or tmp[0].startswith('['):
|
141 |
+
print(tmp)
|
142 |
+
else:
|
143 |
+
n = '旁白'
|
144 |
+
elif len(tmp) == 2:
|
145 |
+
n = tmp[0].split('/')
|
146 |
+
assert len(n) == 3
|
147 |
+
n = n[1]
|
148 |
+
if n in _n:
|
149 |
+
n = _n[n]
|
150 |
+
else:
|
151 |
+
_n[n] = clearT(n)
|
152 |
+
print(line)
|
153 |
+
tmp[-1] = '「' + tmp[-1]
|
154 |
+
else:
|
155 |
+
print(tmp)
|
156 |
+
assert False
|
157 |
+
d = tmp[-1]
|
158 |
+
d = clearT(d)
|
159 |
+
if d:
|
160 |
+
sc[name].append(n + ':' + d)
|
161 |
+
# =================
|
162 |
+
|
163 |
+
for k, v in sc.items():
|
164 |
+
with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f:
|
165 |
+
f.write('\n'.join(v))
|
166 |
+
|
167 |
+
# =================
|
168 |
+
import json
|
169 |
+
tmp = json.dumps(_n, ensure_ascii=False, indent=2)
|