Datasets:

Languages:
Chinese
Tags:
Not-For-All-Audiences
License:
Limour commited on
Commit
0dccccc
·
verified ·
1 Parent(s): 74f7224

Upload 3 files

Browse files
v-corpus-zh/Navel/近月少女的礼仪/少女理论及其周边/ecole_共通.txt.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:baaa5881aadc261830e07a0d53f6691b13d6d80671c22d939a2ed95a3476471d
3
+ size 507301
v-corpus-zh/Navel/近月少女的礼仪/少女理论及其周边/ecole_里想奈.txt.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:86293ea5dbcacd8706701e9b0fe38feae9508d85a39407a0f515d7034dd5618b
3
+ size 334585
v-corpus-zh/Navel/近月少女的礼仪/少女理论及其周边/tmp_ecole.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import fitz
2
+
3
+ print(fitz.__doc__)
4
+
5
+ a = r'E:\tmp\jysn\ecole_v1.0s1_ln.pdf'
6
+
7
+ _end = {'」', '。', '…', '?', '!'}
8
+
9
+ _lines = []
10
+
11
+ doc = fitz.open(a) # open a document
12
+ TIT = False
13
+ for page in doc: # iterate the document pages
14
+ text = page.get_text("blocks") # get plain text encoded as UTF-8
15
+ if len(text) <= 0:
16
+ continue
17
+ tmp = text[0][4]
18
+ tmp = tmp.split(' ')
19
+ if len(tmp) != 2 or not tmp[0].isdigit() or tmp[1] != '\n':
20
+ continue
21
+ # print(tmp)
22
+ if tmp[0] == '405':
23
+ break
24
+ i = 0
25
+ _l = len(text) - 2
26
+ while i <= _l:
27
+ i += 1 # 跳过第一行的页码
28
+ if TIT:
29
+ TIT = False
30
+ line = '章名:' + text[i][4].strip()
31
+ if line[-1] not in _end:
32
+ line += '。'
33
+ print('跨页TIT', line)
34
+ if text[i][4].startswith('TIT \n'): # 小标题
35
+ line = text[i][4][5:].strip()
36
+ if line:
37
+ line = '章名:' + line
38
+ else:
39
+ TIT = True
40
+ continue # 服了,这居中标记还能跨页。。。
41
+ if line[-1] not in _end:
42
+ line += '。'
43
+ print(line)
44
+ else:
45
+ line = text[i][4].strip()
46
+ if not line:
47
+ continue
48
+ if line.startswith('BGT') and line.endswith(_lines[-1]): # 章节之间的空白
49
+ _lines[-1] = '卷名:' + _lines[-1] + '。'
50
+ continue
51
+ _lines.append(line)
52
+
53
+ data = []
54
+
55
+ 左括号 = False
56
+ cache = ''
57
+
58
+ skip = {
59
+ '布琉艾特大人作为首领,其性格上就是「我只是在说:因为无法原谅,'
60
+ }
61
+
62
+ i = -1
63
+ _l = len(_lines) - 2
64
+ while i <= _l:
65
+ i += 1
66
+ line = _lines[i]
67
+ # print(line)
68
+ # tmp = line[-1]
69
+ # _end[tmp] = _end.get(tmp, 0) + 1
70
+ line = line.replace(':\n「', ':「')
71
+ line = line.replace(': 「', ':「')
72
+ line = line.replace('\n', '\\n')
73
+ if ':「' in line:
74
+ if cache != '':
75
+ print('误判', (cache, line)) # 之前误判的
76
+ if 左括号:
77
+ data.append(cache)
78
+ else:
79
+ data.append('旁白:' + cache)
80
+ cache = ''
81
+
82
+ 左括号 = True
83
+
84
+ if not 左括号 and '「' in line:
85
+ print('待处理', repr(line))
86
+ if line.count('「') != line.count('」'):
87
+ if (':' not in line and ':' not in line) or line in skip:
88
+ pass
89
+ else:
90
+ print('异常中断')
91
+ break # 手动处理错误
92
+
93
+ 左括号 = False
94
+
95
+ if not 左括号:
96
+ if line[-1] in _end:
97
+ data.append('旁白:' + cache + line)
98
+ cache = ''
99
+ else:
100
+ cache += line
101
+ else:
102
+ if line[-1] == '」':
103
+ data.append(cache + line)
104
+ cache = ''
105
+ 左括号 = False
106
+ else:
107
+ cache += line
108
+
109
+
110
+ # sorted_word_freq = sorted(_end.items(), key=lambda x: x[1], reverse=True)
111
+
112
+ b = r'D:\datasets\tmp'
113
+ k = 'ecole_里想奈'
114
+ v = data
115
+ with open(b + f'\\{k}.txt', 'w', encoding='utf-8') as f:
116
+ f.write('\n'.join(v))