dialog_processor.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:lasagne_seq2seq 作者: nicolas-ivanov 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号