0

我正在尝试在 Python chatterbot 中组合多个逻辑适配器。我似乎无法正确处理。我试过这个:

english_bot = ChatBot("English Bot", 
storage_adapter="chatterbot.storage.SQLStorageAdapter",
multi_logic_adapter = [
    "chatterbot.logic.MathematicalEvaluation",
    "chatterbot.logic.TimeLogicAdapter",
    "chatterbot.logic.BestMatch"]
)

只有 BestMatch 似乎是活跃的我试过这个:

english_bot = ChatBot("English Bot", 
storage_adapter="chatterbot.storage.SQLStorageAdapter",
logic_adapter = [
    "chatterbot.logic.multi_adapter.MultiLogicAdapter", 
    "chatterbot.logic.MathematicalEvaluation",
    "chatterbot.logic.TimeLogicAdapter",
    "chatterbot.logic.BestMatch"]
)

但我收到此错误:AttributeError: 'NoneType' object has no attribute 'confidence' 并且没有任何 logic_adapter 似乎处于活动状态。

谢谢, 香草

4

4 回答 4

0

Multi Logic 适配器是一个内置类,在代码中没有明确定义。你可以在介绍部分看到这样的声明:“ChatterBot内部使用了一个特殊的逻辑适配器,允许它选择由任意数量的其他逻辑适配器生成的最佳响应" 这是链接 - http://chatterbot.readthedocs.io/en/stable/logic/multi-logic-adapter.html

此外,stackover flow 上已经提供了类似的查询。也参考这个。 使用聊天机器人时出错

于 2018-06-28T06:41:08.640 回答
0

MultiLogicAdapter通常不会以这种方式直接使用。

您添加到的每个逻辑适配器都将由 ChatterBot 内部logic_adapters=[]处理MultiLogicAdapter,无需明确指定。

于 2020-03-13T20:35:14.057 回答
0

最佳匹配

Adapter 是 chatterbot 的默认适配器,您不需要明确指定。更多信息http://chatterbot.readthedocs.io/en/stable/logic/index.html#best-match-adapter

你的代码应该是这样的

# -*- coding: utf-8 -*-
from chatterbot import ChatBot

bot = ChatBot(
    "English Bot",
    logic_adapters=[
        "chatterbot.logic.MathematicalEvaluation",
        "chatterbot.logic.TimeLogicAdapter"
    ]
)

# Print an example of getting one math based response
response = bot.get_response("What is 4 + 9?")
print(response)

# Print an example of getting one time based response
response = bot.get_response("What time is it?")
print(response)
于 2017-09-08T11:21:24.653 回答
0

logic_adapters=[]MultiLogicAdapter会自动处理其中的每个逻辑适配器。不过,您可能需要调整置信水平。

有关 MultiLogicAdapter 的更多信息:http: //chatterbot.readthedocs.io/en/stable/logic/multi-logic-adapter.html

于 2018-03-30T17:52:38.317 回答