-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpre_data.py
57 lines (52 loc) · 1.4 KB
/
pre_data.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/5/24 15:56
# @Author : Zhangyuheng
# @File : pre_data.py
# def format_data(filename):
# start = False
# text = []
# meaning = []
# num = 0
# with open(filename, 'r') as file:
# for line in file.readlines():
# if line.strip() == '------------':
# start = True
# continue
# if num == 0:
# num = 1
# elif num == 1:
# num = 2
# elif num == 2:
# num = 3
# elif num == 3:
# text.append(line.strip())
# num = 4
# elif num == 4:
# meaning.append(line.strip())
# num = 0
# else:
# raise EOFError
#
# return text, meaning
#
#
# text, meaning = format_data('data2/伊索寓言.txt')
# print(len(text))
# print(len(meaning))
# def check(filename):
# with open(filename, 'r') as file:
# for num, line in enumerate(file.readlines()):
# if num % 6 == 0:
# if '------------' != line.strip():
# print(num)
# break
#
#
# check('data2/伊索寓言.txt')
'''
数据预处理
train_with_summ.txt 训练
evaluation_without_ground_truth.txt 评估
1. 根据数据集构建字典(50000条最常用分词 剩余的词典)
'''