-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodel2_dataPreparation_2.py
45 lines (33 loc) · 1.73 KB
/
model2_dataPreparation_2.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
import os
from model2_function import make_cvs, clean_string
source_atitcle_folder='D:\\Research\\Data\\BBC News Summary\\BBC News Summary\\News Articles\\sport'
source_summary_folder='D:\\Research\\Data\\BBC News Summary\\BBC News Summary\\Summaries\\sport'
train_cvs = 'D:\\Research\\Data\\BBC News Summary\\BBC News Summary\\cvsFile\\sport\\train.csv'
val_cvs = 'D:\\Research\\Data\\BBC News Summary\\BBC News Summary\\cvsFile\\sport\\val.csv'
test_cvs = 'D:\\Research\\Data\\BBC News Summary\\BBC News Summary\\cvsFile\\sport\\test.csv'
list_artitle=os.listdir(source_atitcle_folder)
list_summary=os.listdir(source_summary_folder)
document1=[]
summary1=[]
for i in range(len(list_artitle)):
aticle_path=os.path.join(source_atitcle_folder,list_artitle[i])
summary_path=os.path.join(source_summary_folder,list_summary[i])
artictle_content=""
summary_content=""
with open(aticle_path,'r') as file1 :
for line in file1.readlines():
artictle_content=artictle_content+line
with open(summary_path,'r') as file2:
for line in file2.readlines():
summary_content=summary_content+line
document1.append(summary_content)
summary1.append(artictle_content)
print(len(document1))
print(len(summary1))
for i in range(len(document1)):
print(i)
document1[i]=clean_string(document1[i])
summary1[i]=clean_string(summary1[i])
make_cvs(train_cvs,document1[0:round(len(document1)*0.8)],summary1[0:round(len(summary1)*0.8)])
#make_cvs(val_cvs,document1[round(len(document1)*0.8):round(len(document1)*0.995)],summary1[round(len(summary1)*0.8):round(len(document1)*0.995)])
#make_cvs(test_cvs,document1[round(len(document1)*0.995):len(document1)-1],summary1[round(len(summary1)*0.8):len(summary1)-1])