-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
29 lines (27 loc) · 816 Bytes
/
main.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
chat_list = [
{"question": "It’s time to get up", "answer": "Get up soon"},
{"question": "I usually sleep late on Saturdays", "answer": "Hurry up"},
{"question": "It’s still early", "answer": "Did the alarm go off"}
]
# to do continue
def generate_dict(corpus):
dictionary = None
dictSet = set()
for dict in corpus:
questionArr = dict['question'].split()
answerArr = dict['answer'].split()
for word in questionArr:
dictSet.add(word)
for word in answerArr:
dictSet.add(word)
dictionary = list(dictSet)
return dictionary
STOP_WORDS = {
"PAD": "<PAD>",
"SOS": "<SOS>",
"EOS": "<EOS>"
}
if __name__ == "__main__":
dict = generate_dict(chat_list)
for key in STOP_WORDS:
dict.append(STOP_WORDS[key])