zoukankan      html  css  js  c++  java
  • ChatterBot

    1. 安装更新

    $ pip install chatterbot
    $ pip install chatterbot --upgrade
    

    2. 创建机器人

    from chatterbot import ChatBot
    chatbot = ChatBot("Ron Obvious")
    

    3. 训练机器人

    from chatterbot.trainers import ListTrainer
    
    conversation = [
        "Hello",
        "Hi there!",
        "How are you doing?",
        "I'm doing great.",
        "That is good to hear",
        "Thank you.",
        "You're welcome."
    ]
    
    chatbot.set_trainer(ListTrainer)
    chatbot.train(conversation)
    

    4. 获取机器人回复

    response = chatbot.get_response("Good morning!")
    print(response)
    

    5. 只读模式

    ChatterBot机器人每次接收到输入时都会自主进行学习,如果已经训练好机器人之后,不希望机器人再进行自主学习,可以设置为只读模式。当然可以使用这一特性来区分增量学习与生产应用。

    chatbot = ChatBot("Johnny Five", read_only=True)
    
  • 相关阅读:
    Sony Z1 USB 调试
    消除“Unfortunately, System UI has stopped”的方法
    变动数据模拟cons
    string to integer
    single number
    罗马数字转为阿拉伯数字
    整数逆序
    回文数字
    回文字符串
    count and say
  • 原文地址:https://www.cnblogs.com/zhuhc/p/7787529.html
Copyright © 2011-2022 走看看