-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateDataSet.py
More file actions
executable file
·29 lines (23 loc) · 966 Bytes
/
Copy pathCreateDataSet.py
File metadata and controls
executable file
·29 lines (23 loc) · 966 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
import pickle
PF = open("PulpFiction.txt", "r", encoding='utf8', errors='ignore')
IG = open("IngloriousBasterds.txt", "r", encoding='utf8', errors='ignore')
JB = open("JackieBrown.txt", "r", encoding='utf8', errors='ignore')
RD = open("ReservoirDogs.txt", "r", encoding='utf8', errors='ignore')
DJ = open("Django.txt", "r", encoding='utf8', errors='ignore')
scripts = [PF, IG, JB, RD, DJ]
dialogues = []
for movie in scripts:
lines = movie.readlines()
temp_dialogue = ""
for line in lines:
if line.strip().isupper():
if len(temp_dialogue) > 0:
dialogues.append(temp_dialogue)
temp_dialogue = line.strip()
continue
else:
temp_dialogue = line.strip()
if len(temp_dialogue) > 0:
temp_dialogue = temp_dialogue + " " + line.strip()
with open('all_d.list', 'wb') as d_file:
pickle.dump(dialogues, d_file)