📌  相关文章
📜  在 Python 中创建聊天机器人 - 来源:NAYCode.com - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:13.324000             🧑  作者: Mango

代码示例1
#****************** Create chatbot in Python - Source: NAYCode.com

from nltk.chat.util import Chat, reflections

pairs = [

    [

        r"my name is (.*)",

        ["Hello %1, How are you today ?",]

    ],

    ]

def MyChatbot_test():

    print("Hi, I am your chatbot.")

    chatbot=Chat(pairs, reflections)

    chatbot.converse()

    if __name__ == '__main__':

        MyChatbot_test()