-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (29 loc) · 902 Bytes
/
Copy pathmain.py
File metadata and controls
32 lines (29 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
from filt import filt
from epub2txt import epub2txt as e2t
from fenci import cutIt
def index():
# 转移工作目录
if os.path.exists('index-X') != True:
print('当前目录下找不到index-X文件夹,请确保你已clone了index-X')
return False
# 定义集合用于存储所有epub的路径
epub_paths = []
# 遍历目录
for item in os.walk('.'):
for fn in item[2]:
if '.epub' in fn:
epub_paths.append(os.path.join(item[0], fn))
return epub_paths
index = index()
if index == False :
exit()
with open('index.txt', 'w') as f:
for i in index:
print("Converted: " + i)
text = e2t(i)
text = filt(text)
f.write(text)
print('转换完成,接下来将进行分词操作')
cutIt ('index.txt','index-cut.txt')
print('分词完成,index-cut.txt文件即最终结果')