当前位置: 首页>>代码示例>>Python>>正文


Python chatterbot.ChatBot方法代码示例

本文整理汇总了Python中chatterbot.ChatBot方法的典型用法代码示例。如果您正苦于以下问题:Python chatterbot.ChatBot方法的具体用法?Python chatterbot.ChatBot怎么用?Python chatterbot.ChatBot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在chatterbot的用法示例。


在下文中一共展示了chatterbot.ChatBot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def __init__(self, *args, **kwargs):
        """
        Create & set window variables.
        """
        tk.Tk.__init__(self, *args, **kwargs)

        self.chatbot = ChatBot(
            "GUI Bot",
            storage_adapter="chatterbot.storage.SQLStorageAdapter",
            logic_adapters=[
                "chatterbot.logic.BestMatch"
            ],
            database_uri="sqlite:///database.sqlite3"
        )

        self.title("Chatterbot")

        self.initialize() 
开发者ID:gunthercox,项目名称:ChatterBot,代码行数:20,代码来源:tkinter_gui.py

示例2: get_response

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def get_response(self):
        """
        Get a response from the chatbot and display it.
        """
        user_input = self.usr_input.get()
        self.usr_input.delete(0, tk.END)

        response = self.chatbot.get_response(user_input)

        self.conversation['state'] = 'normal'
        self.conversation.insert(
            tk.END, "Human: " + user_input + "\n" + "ChatBot: " + str(response.text) + "\n"
        )
        self.conversation['state'] = 'disabled'

        time.sleep(0.5) 
开发者ID:gunthercox,项目名称:ChatterBot,代码行数:18,代码来源:tkinter_gui.py

示例3: __init__

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def __init__(self, storage_adapter):
        self.initialize()  # Initialize corpus files
        self.chatbot = ChatBot(
            'Maid-chan',
            trainer='chatterbot.trainers.ChatterBotCorpusTrainer',
            output_adapter="chatterbot.output.OutputAdapter",
            output_format='text',
            storage_adapter=storage_adapter
        )
        self.chatbot.train(
            "chatterbot.corpus.indonesia.conversations",
            "chatterbot.corpus.indonesia.greetings",
            "chatterbot.corpus.english.conversations",
            "chatterbot.corpus.english.greetings",
            "chatterbot.corpus.maidcorpus"  # Custom!
        )
        logging.info("Chatterbot is initialized!") 
开发者ID:freedomofkeima,项目名称:messenger-maid-chan,代码行数:19,代码来源:chatbot.py

示例4: learn_stop

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def learn_stop(event):
	if event.fwd_from:
		return
	chat = event.pattern_match.group(1)
	if MONGO_URI is None:
		await event.edit("Critical Error: Add Your MongoDB connection String in Env vars.")	
		return
	if chat:
		try:
			learn_chat.delete_one({'chat_id':int(chat)})
			await event.edit("ChatBot Auto learning stopped for Chat: "+chat)	
		except Exception as e:
			await event.edit("Error:\n{}".format(str(e)))		 
	else:	 
		chat = event.chat_id
		learn_chat.delete_one({'chat_id':chat})
		await event.edit("ChatBot Auto learning stopped for Chat: "+str(chat))	
	await asyncio.sleep(1)
	await event.delete()

#ChatBot Event Handler 
开发者ID:mkaraniya,项目名称:BotHub,代码行数:23,代码来源:chat_bot1.py

示例5: predict

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def predict(name, text):
    botfolder = "./data/__chatbot/" + name
    service = projectmgr.GetService(name, constants.ServiceTypes.ChatBot)
    botjson = json.loads(service.servicedata)
    bot = getBot(name)
    response = bot.get_response(text.lower())
    result = {"confidence": response.confidence, "response_text": response.text}
    if float(response.confidence) < float(botjson["threshold"]):
        result = {"confidence": response.confidence, "response_text": botjson["default_response"]}
    return result 
开发者ID:tech-quantum,项目名称:sia-cog,代码行数:12,代码来源:chatbot.py

示例6: __init__

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def __init__(self, bot):
        self.bot = bot
        self.settings = dataIO.load_json("data/chatterbot/settings.json")
        self.log = dataIO.load_json("data/chatterbot/log.json")
        self.chatbot = chatterbot.ChatBot("redbot", 
                                          storage_adapter="chatterbot.storage.MongoDatabaseAdapter",
                                          # database="data/chatterbot/db",
                                          logic_adapters=[
                                          "chatterbot.logic.BestMatch",
                                          "chatterbot.logic.TimeLogicAdapter",
                                          "chatterbot.logic.MathematicalEvaluation"]
                                          )
        self.chatbot.set_trainer(ListTrainer) 
开发者ID:TrustyJAID,项目名称:Trusty-cogs-archive,代码行数:15,代码来源:chatterbot.py

示例7: getBot

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def getBot(name):
    botfolder = "./data/__chatbot/" + name
    if not os.path.exists(botfolder):
        os.makedirs(botfolder)

    dbpath = "sqlite:///" + botfolder + "/bot.db"

    bot = ChatBot(
        name,
        storage_adapter='chatterbot.storage.SQLStorageAdapter',
        database_uri=dbpath,
        filters=["chatterbot.filters.RepetitiveResponseFilter"],
        preprocessors=[
            'chatterbot.preprocessors.clean_whitespace',
            'chatterbot.preprocessors.convert_to_ascii'
        ],
        logic_adapters=[
            {
                'import_path': 'chatterbot.logic.BestMatch',
                "statement_comparision_function": "chatterbot.comparisions.levenshtein_distance",
                "response_selection_method": "chatterbot.response_selection.get_first_response"
            }
        ]
    )

    return bot 
开发者ID:tech-quantum,项目名称:sia-cog,代码行数:28,代码来源:chatbot.py

示例8: setUp

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def setUp(self):
        super().setUp()
        self.chatbot = ChatBot(**test_settings.CHATTERBOT) 
开发者ID:gunthercox,项目名称:ChatterBot,代码行数:5,代码来源:base_case.py

示例9: setUp

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def setUp(self):
        self.chatbot = ChatBot('Test Bot', **self.get_kwargs()) 
开发者ID:gunthercox,项目名称:ChatterBot,代码行数:4,代码来源:base_case.py

示例10: setUp

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def setUp(self):
        from chatterbot import ChatBot

        self.chatbot = ChatBot('Agent Jr.') 
开发者ID:gunthercox,项目名称:ChatterBot,代码行数:6,代码来源:test_turing.py

示例11: test_valid_storage_adapter

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def test_valid_storage_adapter(self):
        kwargs = self.get_kwargs()
        kwargs['storage_adapter'] = 'chatterbot.storage.SQLStorageAdapter'
        try:
            self.chatbot = ChatBot('Test Bot', **kwargs)
        except Adapter.InvalidAdapterTypeException:
            self.fail('Test raised InvalidAdapterException unexpectedly!') 
开发者ID:gunthercox,项目名称:ChatterBot,代码行数:9,代码来源:test_adapter_validation.py

示例12: test_invalid_logic_adapter

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def test_invalid_logic_adapter(self):
        kwargs = self.get_kwargs()
        kwargs['logic_adapters'] = ['chatterbot.storage.StorageAdapter']
        with self.assertRaises(Adapter.InvalidAdapterTypeException):
            self.chatbot = ChatBot('Test Bot', **kwargs) 
开发者ID:gunthercox,项目名称:ChatterBot,代码行数:7,代码来源:test_adapter_validation.py

示例13: test_valid_logic_adapter

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def test_valid_logic_adapter(self):
        kwargs = self.get_kwargs()
        kwargs['logic_adapters'] = ['chatterbot.logic.BestMatch']
        try:
            self.chatbot = ChatBot('Test Bot', **kwargs)
        except Adapter.InvalidAdapterTypeException:
            self.fail('Test raised InvalidAdapterException unexpectedly!') 
开发者ID:gunthercox,项目名称:ChatterBot,代码行数:9,代码来源:test_adapter_validation.py

示例14: test_valid_adapter_dictionary

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def test_valid_adapter_dictionary(self):
        kwargs = self.get_kwargs()
        kwargs['storage_adapter'] = {
            'import_path': 'chatterbot.storage.SQLStorageAdapter'
        }
        try:
            self.chatbot = ChatBot('Test Bot', **kwargs)
        except Adapter.InvalidAdapterTypeException:
            self.fail('Test raised InvalidAdapterException unexpectedly!') 
开发者ID:gunthercox,项目名称:ChatterBot,代码行数:11,代码来源:test_adapter_validation.py

示例15: test_invalid_adapter_dictionary

# 需要导入模块: import chatterbot [as 别名]
# 或者: from chatterbot import ChatBot [as 别名]
def test_invalid_adapter_dictionary(self):
        kwargs = self.get_kwargs()
        kwargs['storage_adapter'] = {
            'import_path': 'chatterbot.logic.BestMatch'
        }
        with self.assertRaises(Adapter.InvalidAdapterTypeException):
            self.chatbot = ChatBot('Test Bot', **kwargs) 
开发者ID:gunthercox,项目名称:ChatterBot,代码行数:9,代码来源:test_adapter_validation.py


注:本文中的chatterbot.ChatBot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。