-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCombining.py
36 lines (28 loc) · 932 Bytes
/
Combining.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
import pickle
with open('connections.pickle', 'rb') as handle:
con = pickle.load(handle)
with open('words.pickle', 'rb') as handle:
all_words = pickle.load(handle)
count=0
new={}
with open('cornell_movie_dialogs_corpus\\cornell movie-dialogs corpus\\movie_lines.txt','r') as file:
for sent in file:
a=sent.split(" +++$+++ ")
count=count+1
if count==50000:
print("done")
count=0
for i in con:
nlist=con[i]
for j in con[i]:
if j == a[0]:
b=a[4]
b=b.replace('\n','')
b=b.replace('---',',')
b=b.replace('--',',')
nlist=[b if x==j else x for x in nlist]
con[i]=nlist
print("done")
with open('conversations1.pickle','wb') as f:
pickle.dump(con,f,protocol=pickle.HIGHEST_PROTOCOL)
print("done")