def get_input_sequence(sentence):
"""
Prepare chatbot's input by tokenizing the sentence and adding necessary punctuation marks.
Input: "So what's up, buddy"
Output: ["so", "what", "'", "s", "up", ",", "buddy", ".", "$$$"]
"""
if not sentence:
return [START_TOKEN, EOS_SYMBOL]
# add a dot to the end of the sent in case there is no punctuation mark
if sentence[-1] not in _PUNKT_MARKS:
sentence += '.'
sequence = [START_TOKEN] + tokenize(sentence) + [EOS_SYMBOL]
return sequence
dialog_processor.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录