Upload 2 files
Browse files
视觉小说/format/transient/tmp_transient.py
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from opencc import OpenCC
|
2 |
+
cc = OpenCC('t2s') # 't2s'表示繁体转简体
|
3 |
+
import unicodedata
|
4 |
+
import json
|
5 |
+
|
6 |
+
def fullwidth_to_halfwidth(input_str):
|
7 |
+
return ''.join([unicodedata.normalize('NFKC', char) for char in input_str])
|
8 |
+
|
9 |
+
def clearT(s):
|
10 |
+
s = cc.convert(fullwidth_to_halfwidth(s))
|
11 |
+
return s.lstrip('n').strip().strip(r'\n')
|
12 |
+
def startwithany(s, l):
|
13 |
+
return any(s.startswith(x) for x in l)
|
14 |
+
|
15 |
+
f = open(r'E:\tmp\Renpy\script.rpy', encoding='utf-8')
|
16 |
+
start = False
|
17 |
+
keys = [
|
18 |
+
'$',
|
19 |
+
'stop',
|
20 |
+
'scene',
|
21 |
+
'with',
|
22 |
+
'pause',
|
23 |
+
'play',
|
24 |
+
'show',
|
25 |
+
'voice',
|
26 |
+
'hide',
|
27 |
+
'nvl ',
|
28 |
+
'#',
|
29 |
+
'yalign',
|
30 |
+
'linear',
|
31 |
+
'anchor',
|
32 |
+
'if',
|
33 |
+
'return'
|
34 |
+
]
|
35 |
+
_n = {
|
36 |
+
"z": "老师",
|
37 |
+
"y": "叶雨潇",
|
38 |
+
"nvl_narrator": "旁白",
|
39 |
+
"l": "梁芷柔",
|
40 |
+
"a": "同学A",
|
41 |
+
"b": "同学B",
|
42 |
+
"c": "其他同学",
|
43 |
+
"who": "?",
|
44 |
+
"az": "医生",
|
45 |
+
"k": "护士",
|
46 |
+
"kfc": "服务员",
|
47 |
+
"d": "店员",
|
48 |
+
"bird": "候鸟",
|
49 |
+
"yl": "叶雨潇&梁芷柔",
|
50 |
+
"loli": "小梁芷柔",
|
51 |
+
"e": "同学们",
|
52 |
+
"f": "女同学",
|
53 |
+
"g": "同学",
|
54 |
+
"ab": "同学A&B",
|
55 |
+
"m": "广播",
|
56 |
+
"h": "工作人员",
|
57 |
+
"i": "保安",
|
58 |
+
"j": "李金凡",
|
59 |
+
"bird2": "海鸟",
|
60 |
+
"phone": "电话"
|
61 |
+
}
|
62 |
+
sc = []
|
63 |
+
b = open(r'D:\datasets\b-corpus\视觉小说\format\transient\transient.txt','w',encoding='utf-8')
|
64 |
+
for line in f:
|
65 |
+
if line.startswith('label start:'):
|
66 |
+
start = True
|
67 |
+
continue
|
68 |
+
if not start:
|
69 |
+
continue
|
70 |
+
line = line.strip()
|
71 |
+
if not line:
|
72 |
+
continue
|
73 |
+
if startwithany(line, keys):
|
74 |
+
continue
|
75 |
+
if line.startswith('"'):
|
76 |
+
n = '旁白'
|
77 |
+
if startwithany(line, _n.keys()) and ' ' in line:
|
78 |
+
idx = line.index(' ')
|
79 |
+
n = line[:idx]
|
80 |
+
n = _n[n]
|
81 |
+
line = line[idx:].strip()
|
82 |
+
左引号 = line.index('"')
|
83 |
+
右引号 = line.rindex('"') + 1
|
84 |
+
d = line[左引号:右引号]
|
85 |
+
sc.append(n + ':' + clearT(d))
|
86 |
+
b.write('\n'.join(sc))
|
87 |
+
f.close()
|
88 |
+
b.close()
|
89 |
+
tmp = json.dumps(_n, ensure_ascii=False, indent=2)
|
视觉小说/format/transient/transient.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c46b204193b6d1e40b64e785143b4cf6899a82c1b4514a5e4e884bba2ca6f48b
|
3 |
+
size 204010
|