Upload 12 files
Browse files- v-corpus-zh/FrontWing/ISLAND/BAD.txt.gz +3 -0
- v-corpus-zh/FrontWing/ISLAND/EDM.txt.gz +3 -0
- v-corpus-zh/FrontWing/ISLAND/ISLAND_cstl.py +173 -0
- v-corpus-zh/FrontWing/ISLAND/OPM.txt.gz +3 -0
- v-corpus-zh/FrontWing/ISLAND/SAR.txt.gz +3 -0
- v-corpus-zh/FrontWing/ISLAND/com.txt.gz +3 -0
- v-corpus-zh/FrontWing/ISLAND/cst2txt.py +316 -0
- v-corpus-zh/FrontWing/ISLAND/cstl2txt.py +47 -0
- v-corpus-zh/FrontWing/ISLAND/kar.txt.gz +3 -0
- v-corpus-zh/FrontWing/ISLAND/lin.txt.gz +3 -0
- v-corpus-zh/FrontWing/ISLAND/sum.txt.gz +3 -0
- v-corpus-zh/FrontWing/ISLAND/win.txt.gz +3 -0
v-corpus-zh/FrontWing/ISLAND/BAD.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:38ac70e165285b83137bd4d1827d22d935d125373c8b574f83ed42499282ba49
|
3 |
+
size 19387
|
v-corpus-zh/FrontWing/ISLAND/EDM.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cc07755267052800d2134c2599a1e87c391e4e414d4e5df69f79c4400de620e8
|
3 |
+
size 38001
|
v-corpus-zh/FrontWing/ISLAND/ISLAND_cstl.py
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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\ISLAND\cst', ext='.cstl')
|
40 |
+
b = r'D:\datasets\tmp'
|
41 |
+
# =================
|
42 |
+
|
43 |
+
sc = {}
|
44 |
+
|
45 |
+
_n = {
|
46 |
+
"旁白": "旁白",
|
47 |
+
"镇长": "镇长",
|
48 |
+
"声音": "声音",
|
49 |
+
"?": "?",
|
50 |
+
"少女": "少女",
|
51 |
+
"琳": "琳",
|
52 |
+
"女子": "女子",
|
53 |
+
"切那": "切那",
|
54 |
+
"玖音": "玖音",
|
55 |
+
"女孩": "女孩",
|
56 |
+
"纱罗": "纱罗",
|
57 |
+
"夏莲": "夏莲",
|
58 |
+
"巡警": "巡警",
|
59 |
+
"看守": "看守",
|
60 |
+
"桃香": "桃香",
|
61 |
+
"凛音": "凛音",
|
62 |
+
"守春": "守春",
|
63 |
+
"女性": "女性",
|
64 |
+
"切那&夏莲": "切那&夏莲",
|
65 |
+
"Setsuna": "Setsuna",
|
66 |
+
"Linne": "Linne",
|
67 |
+
"Karen": "Karen",
|
68 |
+
"Sarah": "Sarah",
|
69 |
+
"熊孩子A": "熊孩子A",
|
70 |
+
"熊孩子B": "熊孩子B",
|
71 |
+
"熊孩子C": "熊孩子C",
|
72 |
+
"熊孩子们": "熊孩子们",
|
73 |
+
"男性": "男性",
|
74 |
+
"女学生": "女学生",
|
75 |
+
"老奶奶": "老奶奶",
|
76 |
+
"夏莲・纱罗": "夏莲&纱罗",
|
77 |
+
"切那&凛音": "切那&凛音",
|
78 |
+
"船长": "船长",
|
79 |
+
" ": "――",
|
80 |
+
"雨兰": "雨兰",
|
81 |
+
"凛音&切那": "凛音&切那",
|
82 |
+
"老人": "老人",
|
83 |
+
"森须": "森须",
|
84 |
+
"切那・纱罗": "切那&纱罗",
|
85 |
+
"鱼店老板": "鱼店老板",
|
86 |
+
"切那&纱罗": "切那&纱罗",
|
87 |
+
"??": "?",
|
88 |
+
"???": "?",
|
89 |
+
"万??": "万??",
|
90 |
+
"万里?": "万里?",
|
91 |
+
"万里爱": "万里爱",
|
92 |
+
"Nehan": "Nehan",
|
93 |
+
"凛音・纱罗": "凛音&纱罗",
|
94 |
+
"玖音?": "玖音?",
|
95 |
+
"雨兰?": "雨兰?",
|
96 |
+
"玖音&雨兰": "玖音&雨兰",
|
97 |
+
"夏莲&纱罗": "夏莲&纱罗",
|
98 |
+
"――": "――", # 三千界切那 但是此时还不记得自己的名字
|
99 |
+
"孩童": "孩童",
|
100 |
+
"头盖骨?": "头盖骨?",
|
101 |
+
"男孩": "男孩",
|
102 |
+
"Peach": "Peach",
|
103 |
+
"二人": "二人",
|
104 |
+
"男性1": "男性1",
|
105 |
+
"男性2": "男性2",
|
106 |
+
"男性3": "男性3",
|
107 |
+
"老人1": "老人1",
|
108 |
+
"老人2": "老人2",
|
109 |
+
"老人3": "老人3",
|
110 |
+
"卫兵": "卫兵"
|
111 |
+
}
|
112 |
+
|
113 |
+
# =================
|
114 |
+
|
115 |
+
|
116 |
+
def spStrip(s :str):
|
117 |
+
retn = ''
|
118 |
+
_i = -1
|
119 |
+
while _i < len(s) - 1:
|
120 |
+
_i += 1
|
121 |
+
char = s[_i]
|
122 |
+
if char == '\\':
|
123 |
+
_i += 2
|
124 |
+
elif char == '[':
|
125 |
+
_d = True
|
126 |
+
while _i < len(s) - 1:
|
127 |
+
_i += 1
|
128 |
+
char = s[_i]
|
129 |
+
if char == ']':
|
130 |
+
break
|
131 |
+
if char == '/':
|
132 |
+
_d = False
|
133 |
+
if _d:
|
134 |
+
retn += char
|
135 |
+
else:
|
136 |
+
retn += char
|
137 |
+
return retn
|
138 |
+
|
139 |
+
# =================
|
140 |
+
from cstl2txt import getTxt
|
141 |
+
for path in a:
|
142 |
+
name = path[path.rindex('\\'):]
|
143 |
+
name = name[:4]
|
144 |
+
if name not in sc:
|
145 |
+
sc[name] = []
|
146 |
+
print(name)
|
147 |
+
# =================
|
148 |
+
data = getTxt(path)
|
149 |
+
w_i = -1
|
150 |
+
while w_i < len(data) - 1:
|
151 |
+
w_i += 1
|
152 |
+
n = data[w_i]
|
153 |
+
if not n:
|
154 |
+
n = '旁白'
|
155 |
+
w_i += 1
|
156 |
+
d = spStrip(data[w_i])
|
157 |
+
w_i += 2 # skip jp
|
158 |
+
# print(n, d)
|
159 |
+
if n in _n:
|
160 |
+
n = _n[n]
|
161 |
+
else:
|
162 |
+
_n[n] = clearT(n)
|
163 |
+
if d:
|
164 |
+
sc[name].append(n + ':' + d)
|
165 |
+
# =================
|
166 |
+
|
167 |
+
for k, v in sc.items():
|
168 |
+
with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f:
|
169 |
+
f.write('\n'.join(v))
|
170 |
+
|
171 |
+
# =================
|
172 |
+
import json
|
173 |
+
tmp = json.dumps(_n, ensure_ascii=False, indent=2)
|
v-corpus-zh/FrontWing/ISLAND/OPM.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:58ff7fb373647d0ea8895f66a9ec23b0ae3c46fcfd5066534e53f4c6edb4879a
|
3 |
+
size 8783
|
v-corpus-zh/FrontWing/ISLAND/SAR.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bb041f0f28ec13e52ca275423b294a7652f9b08b5e5b054224db3db6dc813630
|
3 |
+
size 132631
|
v-corpus-zh/FrontWing/ISLAND/com.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f7df64eb414c4e37049f1615298b7241affa89516c7a0b73648eb7e995e84bce
|
3 |
+
size 120648
|
v-corpus-zh/FrontWing/ISLAND/cst2txt.py
ADDED
@@ -0,0 +1,316 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# https://zhuanlan.zhihu.com/p/623697843
|
2 |
+
|
3 |
+
# mamba create -n golang -c conda-forge go
|
4 |
+
# conda activate golang
|
5 |
+
# cd E:\tmp\ISLAND
|
6 |
+
# Get-Item -Path Env:\CONDA*
|
7 |
+
# $env:GOROOT = "$env:CONDA_PREFIX\go"
|
8 |
+
# go version
|
9 |
+
# go mod init cst
|
10 |
+
# go get github.com/regomne/eutil/codec
|
11 |
+
# go get github.com/regomne/eutil/textFile
|
12 |
+
# # https://github.com/regomne/chinesize/blob/master/CatSystem2/cstTextProc/cst.go
|
13 |
+
# go build .\cst.go
|
14 |
+
#
|
15 |
+
# E:\tmp\ISLAND\cst.exe -e -cst E:\tmp\ISLAND\cst\BAD_01.cst -o E:\tmp\ISLAND\cst\BAD_01.txt -cp 932
|
16 |
+
|
17 |
+
import os, sys
|
18 |
+
import struct
|
19 |
+
import zlib
|
20 |
+
|
21 |
+
warnings = []
|
22 |
+
|
23 |
+
|
24 |
+
def warn(value):
|
25 |
+
warnings.append(value)
|
26 |
+
|
27 |
+
|
28 |
+
def clearWarnings():
|
29 |
+
global warnings
|
30 |
+
warnings = []
|
31 |
+
|
32 |
+
|
33 |
+
def printWarnings(sc):
|
34 |
+
global warnings
|
35 |
+
for wi in warnings:
|
36 |
+
print('[WARNING]', sc, wi)
|
37 |
+
clearWarnings()
|
38 |
+
|
39 |
+
|
40 |
+
def cst2bin(datcst):
|
41 |
+
tag, sizcst, sizbin = struct.unpack_from('8sII', datcst)
|
42 |
+
if tag != b'CatScene':
|
43 |
+
raise Exception('Label Mismatch')
|
44 |
+
datcst = datcst[16:]
|
45 |
+
if sizcst != len(datcst):
|
46 |
+
raise Exception('Size Ante Decompress Mismatch')
|
47 |
+
datbin = zlib.decompress(datcst)
|
48 |
+
if sizbin != len(datbin):
|
49 |
+
raise Exception('Size Post Decompress Mismatch')
|
50 |
+
return datbin
|
51 |
+
|
52 |
+
|
53 |
+
def bin2cst(datbin):
|
54 |
+
datcst = zlib.compress(datbin)
|
55 |
+
return b'CatScene' + struct.pack('II', len(datcst), len(datbin)) + datcst
|
56 |
+
|
57 |
+
|
58 |
+
class FormatCST:
|
59 |
+
def __init__(self, fc):
|
60 |
+
b = cst2bin(fc.read())
|
61 |
+
(h0, self.h1, self.h2, self.h3), b = struct.unpack_from('4I', b), b[16:]
|
62 |
+
self.b1, b2, b3 = b[:self.h2], b[self.h2:self.h3], b[self.h3:]
|
63 |
+
if h0 != len(b) or self.h1 * 8 != self.h2 or (self.h3 - self.h2) % 4 != 0:
|
64 |
+
raise Exception('Integrity Constraint 0 Violated')
|
65 |
+
|
66 |
+
it = struct.iter_unpack('II', self.b1)
|
67 |
+
flag = True
|
68 |
+
self.n1 = 0
|
69 |
+
while flag:
|
70 |
+
try:
|
71 |
+
d10, d11 = next(it)
|
72 |
+
if d11 != self.n1:
|
73 |
+
flag = False
|
74 |
+
self.n1 += d10
|
75 |
+
except StopIteration:
|
76 |
+
break
|
77 |
+
if not flag or self.n1 * 4 != self.h3 - self.h2:
|
78 |
+
raise Exception('Integrity Constraint 1 Violated')
|
79 |
+
|
80 |
+
it = struct.iter_unpack('I', b2)
|
81 |
+
d2 = []
|
82 |
+
while True:
|
83 |
+
try:
|
84 |
+
d2.append(*next(it))
|
85 |
+
except StopIteration:
|
86 |
+
break
|
87 |
+
if self.n1 != len(d2):
|
88 |
+
raise Exception('Integrity Constraint 2 Violated')
|
89 |
+
|
90 |
+
ofs = 0
|
91 |
+
self.d3 = []
|
92 |
+
for i in range(self.n1):
|
93 |
+
if ofs < d2[i]:
|
94 |
+
warn('Unaccessible Fragment Offset 0x{0:08X}'.format(ofs))
|
95 |
+
ofs = d2[i]
|
96 |
+
if ofs > d2[i]:
|
97 |
+
raise Exception('Overflow Offset 0x{0:08X}'.format(ofs))
|
98 |
+
try:
|
99 |
+
d30, d31, d32 = struct.unpack_from('3B', b3, ofs)
|
100 |
+
except Exception:
|
101 |
+
raise Exception('Content Truncated')
|
102 |
+
if d30 != 0x01:
|
103 |
+
raise Exception('Invalid Offset 0x{0:08X}'.format(ofs))
|
104 |
+
if d31 not in (0x02, 0x20, 0x21, 0x30):
|
105 |
+
warn('Unknown Code 0x01{1:02X} Offset 0x{0:08X}'.format(ofs, d31))
|
106 |
+
ofs += 3
|
107 |
+
while d32 != 0x00:
|
108 |
+
try:
|
109 |
+
d32, = struct.unpack_from('B', b3, ofs)
|
110 |
+
except Exception:
|
111 |
+
raise Exception('Content Truncated')
|
112 |
+
ofs += 1
|
113 |
+
self.d3.append(b3[d2[i]: ofs])
|
114 |
+
if ofs < len(b3):
|
115 |
+
warn('Unaccessible Fragment Offset 0x{0:08X}'.format(ofs))
|
116 |
+
|
117 |
+
def iter(self):
|
118 |
+
self.idx = -1
|
119 |
+
self.fslc = False
|
120 |
+
|
121 |
+
def next(self, skp=True):
|
122 |
+
self.idx += 1
|
123 |
+
if skp:
|
124 |
+
while self.idx < self.n1:
|
125 |
+
if self.fslc:
|
126 |
+
break
|
127 |
+
d31, = struct.unpack_from('B', self.d3[self.idx], 1)
|
128 |
+
if d31 in (0x20, 0x21):
|
129 |
+
break
|
130 |
+
if d31 == 0x30 and self.d3[self.idx][2:8] == b'scene\x20':
|
131 |
+
break
|
132 |
+
if d31 == 0x30 and self.d3[self.idx][2:] == b'fselect\x00':
|
133 |
+
self.fslc = True
|
134 |
+
self.idx += 1
|
135 |
+
if self.idx >= self.n1:
|
136 |
+
raise StopIteration
|
137 |
+
|
138 |
+
def get(self, skp=True):
|
139 |
+
if skp:
|
140 |
+
return self.d3[self.idx][2:-1]
|
141 |
+
else:
|
142 |
+
return b'<\\x01><\\x' + bytes('{0:02X}'.format(self.d3[self.idx][1]), encoding='utf-8') + b'>' + self.d3[
|
143 |
+
self.idx][
|
144 |
+
2:-1] + b'<\\x00>'
|
145 |
+
|
146 |
+
def rep(self, bn):
|
147 |
+
self.d3[self.idx] = self.d3[self.idx][:2] + bn + b'\x00'
|
148 |
+
|
149 |
+
def pac(self):
|
150 |
+
b2, b3 = b'', b''
|
151 |
+
ofs = 0
|
152 |
+
for i in range(self.n1):
|
153 |
+
b2 += struct.pack('I', ofs)
|
154 |
+
b3 += self.d3[i]
|
155 |
+
ofs += len(self.d3[i])
|
156 |
+
b0 = struct.pack('4I', self.h3 + ofs, self.h1, self.h2, self.h3)
|
157 |
+
return b0 + self.b1 + b2 + b3
|
158 |
+
|
159 |
+
|
160 |
+
pathcst = 'scene_cst'
|
161 |
+
pathbin = 'scene_bin'
|
162 |
+
pathtxt = 'scene_txt'
|
163 |
+
pathdst = 'scene_dst'
|
164 |
+
|
165 |
+
|
166 |
+
def depacst():
|
167 |
+
liscst = os.listdir(pathcst)
|
168 |
+
if not os.path.exists(pathbin):
|
169 |
+
os.makedirs(pathbin)
|
170 |
+
s0, s1 = 0, 0
|
171 |
+
for sc in liscst:
|
172 |
+
if not sc.endswith('.cst'):
|
173 |
+
continue
|
174 |
+
s1 += 1
|
175 |
+
clearWarnings()
|
176 |
+
|
177 |
+
f = open(os.path.join(pathcst, sc), 'rb')
|
178 |
+
try:
|
179 |
+
b = cst2bin(f.read())
|
180 |
+
except Exception as e:
|
181 |
+
print('[ERROR]', sc, e)
|
182 |
+
continue
|
183 |
+
finally:
|
184 |
+
f.close()
|
185 |
+
|
186 |
+
sb = sc[:-3] + 'bin'
|
187 |
+
f = open(os.path.join(pathbin, sb), 'wb')
|
188 |
+
f.write(b)
|
189 |
+
f.close()
|
190 |
+
|
191 |
+
s0 += 1
|
192 |
+
printWarnings(sc)
|
193 |
+
return (s0, s1)
|
194 |
+
|
195 |
+
|
196 |
+
def unpacst(skp=True):
|
197 |
+
liscst = os.listdir(pathcst)
|
198 |
+
if not os.path.exists(pathtxt):
|
199 |
+
os.makedirs(pathtxt)
|
200 |
+
s0, s1 = 0, 0
|
201 |
+
for sc in liscst:
|
202 |
+
if not sc.endswith('.cst'):
|
203 |
+
continue
|
204 |
+
s1 += 1
|
205 |
+
clearWarnings()
|
206 |
+
|
207 |
+
f = open(os.path.join(pathcst, sc), 'rb')
|
208 |
+
try:
|
209 |
+
c = FormatCST(f)
|
210 |
+
except Exception as e:
|
211 |
+
print('[ERROR]', sc, e)
|
212 |
+
continue
|
213 |
+
finally:
|
214 |
+
f.close()
|
215 |
+
|
216 |
+
st = sc[:-3] + 'txt'
|
217 |
+
f = open(os.path.join(pathtxt, st), 'wb')
|
218 |
+
c.iter()
|
219 |
+
while True:
|
220 |
+
try:
|
221 |
+
c.next(skp)
|
222 |
+
f.write(c.get(skp))
|
223 |
+
f.write(b'\x0D\x0A')
|
224 |
+
except StopIteration:
|
225 |
+
break
|
226 |
+
f.close()
|
227 |
+
|
228 |
+
s0 += 1
|
229 |
+
printWarnings(sc)
|
230 |
+
return (s0, s1)
|
231 |
+
|
232 |
+
|
233 |
+
def repacst():
|
234 |
+
liscst = os.listdir(pathcst)
|
235 |
+
listxt = os.listdir(pathtxt)
|
236 |
+
if not os.path.exists(pathdst):
|
237 |
+
os.makedirs(pathdst)
|
238 |
+
s0, s1 = 0, 0
|
239 |
+
for st in listxt:
|
240 |
+
if not st.endswith('.txt'):
|
241 |
+
continue
|
242 |
+
sc = st[:-3] + 'cst'
|
243 |
+
if sc not in liscst:
|
244 |
+
print('[WARNING] Original CST File Missing: ' + sc)
|
245 |
+
continue
|
246 |
+
s1 += 1
|
247 |
+
clearWarnings()
|
248 |
+
|
249 |
+
f = open(os.path.join(pathcst, sc), 'rb')
|
250 |
+
try:
|
251 |
+
c = FormatCST(f)
|
252 |
+
except Exception as e:
|
253 |
+
print('[ERROR]', sc, e)
|
254 |
+
continue
|
255 |
+
finally:
|
256 |
+
f.close()
|
257 |
+
|
258 |
+
st = sc[:-3] + 'txt'
|
259 |
+
f = open(os.path.join(pathtxt, st), 'rb')
|
260 |
+
c.iter()
|
261 |
+
flag = True
|
262 |
+
s = 0
|
263 |
+
while True:
|
264 |
+
try:
|
265 |
+
c.next()
|
266 |
+
bn = b''
|
267 |
+
while True:
|
268 |
+
bi = f.read(1)
|
269 |
+
di, = struct.unpack('B', bi)
|
270 |
+
if di < 0x20:
|
271 |
+
break
|
272 |
+
bn += bi
|
273 |
+
if di != 0x0D:
|
274 |
+
flag = False
|
275 |
+
break
|
276 |
+
bi = f.read(1)
|
277 |
+
di, = struct.unpack('B', bi)
|
278 |
+
if di != 0x0A:
|
279 |
+
flag = False
|
280 |
+
break
|
281 |
+
c.rep(bn)
|
282 |
+
s += 1
|
283 |
+
except StopIteration:
|
284 |
+
break
|
285 |
+
except Exception:
|
286 |
+
warn('Lack of Text')
|
287 |
+
break
|
288 |
+
f.close()
|
289 |
+
if not flag:
|
290 |
+
print('[ERROR]', st, 'Invalid Byte 0x{0:02X}'.format(di))
|
291 |
+
continue
|
292 |
+
f = open(os.path.join(pathdst, sc), 'wb')
|
293 |
+
f.write(bin2cst(c.pac()))
|
294 |
+
f.close()
|
295 |
+
|
296 |
+
s0 += 1
|
297 |
+
printWarnings(sc)
|
298 |
+
return (s0, s1)
|
299 |
+
|
300 |
+
|
301 |
+
if __name__ == '__main__':
|
302 |
+
pathcst = r'E:\tmp\ISLAND\cst'
|
303 |
+
liscst = os.listdir(pathcst)
|
304 |
+
tag = 0
|
305 |
+
if tag not in (0, 1, 2, 3):
|
306 |
+
print('Invalid Parametre')
|
307 |
+
sys.exit()
|
308 |
+
if tag == 0:
|
309 |
+
s0, s1 = unpacst()
|
310 |
+
if tag == 1:
|
311 |
+
s0, s1 = repacst()
|
312 |
+
if tag == 2:
|
313 |
+
s0, s1 = depacst()
|
314 |
+
if tag == 3:
|
315 |
+
s0, s1 = unpacst(False)
|
316 |
+
print('%d / %d completed' % (s0, s1))
|
v-corpus-zh/FrontWing/ISLAND/cstl2txt.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import struct
|
2 |
+
|
3 |
+
|
4 |
+
def getLen(_f):
|
5 |
+
_data = _f.read(1)
|
6 |
+
_a_l = _l = _data[0]
|
7 |
+
while _l == 255:
|
8 |
+
_data = _f.read(1)
|
9 |
+
_l = _data[0]
|
10 |
+
_a_l += _l
|
11 |
+
return _a_l
|
12 |
+
|
13 |
+
|
14 |
+
# with open('E:\\tmp\\ISLAND\\cst\\lin03_selA_ret.cstl', 'rb') as f:
|
15 |
+
# data = f.read(8)
|
16 |
+
# Header = struct.unpack_from('4sI', data)
|
17 |
+
# print(Header)
|
18 |
+
# al_len = getLen(f)
|
19 |
+
# for i in range(al_len):
|
20 |
+
# data = f.read(getLen(f))
|
21 |
+
# print(data)
|
22 |
+
# al_len = getLen(f) * al_len * 2
|
23 |
+
# print('len', al_len)
|
24 |
+
# while al_len > 0:
|
25 |
+
# data = f.read(getLen(f))
|
26 |
+
# print(data.decode('utf-8'))
|
27 |
+
# al_len -= 1
|
28 |
+
|
29 |
+
|
30 |
+
def getTxt(path):
|
31 |
+
retn = []
|
32 |
+
with open(path, 'rb') as f:
|
33 |
+
data = f.read(8)
|
34 |
+
Header = struct.unpack_from('4sI', data)
|
35 |
+
print(Header)
|
36 |
+
al_len = getLen(f)
|
37 |
+
for i in range(al_len):
|
38 |
+
data = f.read(getLen(f))
|
39 |
+
print('语言', data)
|
40 |
+
al_len = getLen(f) * al_len * 2
|
41 |
+
print('数量', al_len)
|
42 |
+
while al_len > 0:
|
43 |
+
data = f.read(getLen(f))
|
44 |
+
retn.append(data.decode('utf-8'))
|
45 |
+
al_len -= 1
|
46 |
+
assert not f.read(1)
|
47 |
+
return retn
|
v-corpus-zh/FrontWing/ISLAND/kar.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:48ba1d0603f7e518500854efa691d828bbb78296b960f63d56a69fccf7a124a4
|
3 |
+
size 126240
|
v-corpus-zh/FrontWing/ISLAND/lin.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b09070cca47fd895a14b2ea84b21b55ac74551a3e1ee47e86809cb8e47ba72f6
|
3 |
+
size 148393
|
v-corpus-zh/FrontWing/ISLAND/sum.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e88314692d043a31ae733d68010b524786e79bc6819e6c1a97cbd40ccef176f5
|
3 |
+
size 103962
|
v-corpus-zh/FrontWing/ISLAND/win.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3c62794bb173bafebf449b098378b980abaf08a7146be996d08a1bb940a938bc
|
3 |
+
size 246696
|