response.py 文件源码

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

项目:goose 作者: sexxis 项目源码 文件源码
def run_bot(user_input, start):
    """
    :param(str) user_input: Message sent to the bot
    :param(bool) start: If the user is new to the bot
    :return(str) return: Response from the bot
    """
    if start:
        bot.response = "Hello there! Have a chat with me or say 'help' to see available commands :)"
        return bot.response

    bot.user_input = user_input

    # fix_typos:    Fix any user typos and slang
    # check_phrase_similarity:  Check user's input similarity to all key phrases
    # create_response:  If all key phrases fail, we gotta actually make a new sentence
    for method in ['fix_typos', 'help_check', 'check_phrase_similarity', 'create_response']:
        if operator.methodcaller(method)(bot):
            return bot.response
    return random.choice(responses.UNSURE)  # If no response can be created


# For testing purposes
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号