Skip to content

Commit

Permalink
feat: 添加生成字典函数
Browse files Browse the repository at this point in the history
  • Loading branch information
qtencent7 committed Mar 30, 2024
0 parents commit e8e96be
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
29 changes: 29 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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])

0 comments on commit e8e96be

Please sign in to comment.