Datasets:

Languages:
Chinese
Tags:
Not-For-All-Audiences
License:
Limour commited on
Commit
879cbcb
·
verified ·
1 Parent(s): 0b4f306

Upload 2 files

Browse files
视觉小说/format/ever17/ever17.txt.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60775a56967cc82d7390084abbe4e6224364cbeb4a9bc5d1fe2c45b51b76c958
3
+ size 559646
视觉小说/format/ever17/tmp_ever17.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import chardet
2
+ from opencc import OpenCC
3
+ cc = OpenCC('t2s') # 't2s'表示繁体转简体
4
+ from h_corpus import Fileset
5
+ import unicodedata
6
+ import json
7
+
8
+ def fullwidth_to_halfwidth(input_str):
9
+ return ''.join([unicodedata.normalize('NFKC', char) for char in input_str])
10
+
11
+ def clearT(s):
12
+ s = cc.convert(fullwidth_to_halfwidth(s))
13
+ return s.lstrip('n').strip().strip(r'\n')
14
+ def s_in(s, ss, es):
15
+ return [x.split(es)[0] for x in s.split(ss) if es in x]
16
+
17
+ _n = {
18
+ "??": "?",
19
+ "少年": "少年",
20
+ "优": "优",
21
+ "玛由": "玛由",
22
+ "沙罗": "沙罗",
23
+ "男孩": "男孩",
24
+ "女孩": "女孩",
25
+ "武": "武",
26
+ "空": "空",
27
+ "全体": "全体",
28
+ "鸠": "鸠",
29
+ "少女": "少女",
30
+ "松永": "松永",
31
+ "社长": "社长",
32
+ "可可": "可可",
33
+ "优、沙罗": "优&沙罗",
34
+ "女": "女",
35
+ "男": "男",
36
+ "广播": "广播",
37
+ "田中博士": "田中博士",
38
+ "职员": "职员",
39
+ "皮皮": "皮皮",
40
+ "空A": "空A",
41
+ "空B": "空B",
42
+ "空C": "空C",
43
+ "月": "月",
44
+ "假的空": "假的空",
45
+ "研究员": "研究员",
46
+ "警备长": "警备长",
47
+ "月海": "月海",
48
+ "医师": "医师",
49
+ "桑古木": "桑古木",
50
+ "优秋": "优秋",
51
+ "优春": "优春",
52
+ "BW": "BW",
53
+ "管制官": "管制官",
54
+ "北斗": "北斗",
55
+ "狸": "狸",
56
+ "游客": "游客"
57
+ }
58
+
59
+
60
+ with open(r'E:\tmp\script.txt', 'rb') as f:
61
+ tmp = f.read()
62
+ b = open(r'E:\tmp\script_01.txt', 'w', encoding='utf-8')
63
+ sep = b'\x05\x80\x00\x00'
64
+ eos = b'\x02\x03\x0e'
65
+ encode = 'GB2312'
66
+ tmp = tmp.split(sep)
67
+ 左括号 = b'\xa1\xbe'
68
+ 右括号 = b'\xa1\xbf'
69
+ 左引号 = b'\xa1\xb8'
70
+ 右引号 = b'\xa1\xb9'
71
+ sc = []
72
+ for line in tmp:
73
+ if eos not in line:
74
+ continue
75
+ idx = line.index(eos)
76
+ line = line[:idx]
77
+ line = line.strip(b'\x00\x00')
78
+ if b'\x00\x00' in line:
79
+ continue
80
+ # encode = chardet.detect(line)
81
+ # if encode['confidence'] > 0.9:
82
+ # print(encode['encoding'])
83
+ if 左括号 in line and 右括号 in line:
84
+ n = s_in(line, 左括号, 右括号)
85
+ assert len(n) == 1
86
+ n = n[0].decode(encoding=encode)
87
+ if 左引号 in line:
88
+ r_idx = line.index(右括号)
89
+ l_idx = line.index(左引号)
90
+ if l_idx - r_idx == 3:
91
+ line = line[l_idx:]
92
+ # _n[n] = clearT(n)
93
+ n = _n[n]
94
+ else:
95
+ n = '旁白'
96
+ if 左引号 in line and 右引号 in line:
97
+ line = line[:line.rindex(右引号)+2]
98
+ d = clearT(line.decode(encoding=encode).replace('\n', '\\n')).replace('\x01', '')
99
+ # if '不但不苦,而且吃下去之后,还会有一股芳香甘醇的' in d:
100
+ # print(line)
101
+ # break
102
+ if d:
103
+ sc.append(n + ':' + d)
104
+ b.write('\n'.join(sc))
105
+ b.close()
106
+
107
+ tmp = json.dumps(_n, ensure_ascii=False, indent=2)