-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp.py
More file actions
23 lines (21 loc) · 862 Bytes
/
temp.py
File metadata and controls
23 lines (21 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def load_conversations():
id2line = {}
with open(path_to_movie_lines, errors='ignore') as f:
lines = f.readlines()
for line in lines:
line = line.replace("\n","")
parts = line.split(" +++$+++ ")
id2line[parts[0]] = parts[4]
inputs, outputs = [], []
with open(path_to_movie_conversations, 'r') as file:
lines = file.readlines()
for line in lines:
line = line.replace("\n","")
parts = line.split(" +++$+++ ")
conversation = [line[1:-1] for line in parts[3][1:-1].split(", ")]
for i in range(len(conversation)-1):
inputs.append(preprocess_sentence(id2line[conversation[i]]))
outputs.append(preprocess_sentence(id2line[conversation[i+1]]))
if len(inputs) >= MAX_SAMPLES:
return inputs, outputs
return inputs, outputs