1

是否可以使用现有数据库训练聊天机器人(使用 ChatterBot)?

我有一个相对较大的 sqlite3 db 文件,其中包含大约 3GB 的对话。如果完全有可能从该数据库中提取答案而不是将其转换为 json 然后创建我自己的语料库,我想这样做。

当我按照他们的教程进行操作时,就是这么说的。

from chatterbot import ChatBot

bot = ChatBot( "Terminal",
    storage_adapter="chatterbot.storage.SQLStorageAdapter",
    logic_adapters=[
    "chatterbot.logic.MathematicalEvaluation",
    "chatterbot.logic.TimeLogicAdapter",
    "chatterbot.logic.BestMatch"
    ],
    input_adapter="chatterbot.input.TerminalAdapter",
    output_adapter="chatterbot.output.TerminalAdapter",
    database="database.db"
   )

print("Type something to begin...")

while True:
    try:
        bot_input = bot.get_response(None)


    except (KeyboardInterrupt, EOFError, SystemExit):
        break

它并没有从中得出答案。它忽略它并使用自己的训练数据。

4

1 回答 1

3

这是可能的,但是您需要编写自己的Trainer类来读取您的 sqlite 文件的内容,以便可以使用它来训练聊天机器人。

另一种方法是编写一个脚本,将您的 sqlite 数据转换为训练语料库格式,以便您可以使用现有方法训练您的机器人。

关于语料库格式的更多信息可以在这里找到: http ://chatterbot-corpus.readthedocs.io/en/latest/data.html

于 2018-05-04T21:28:15.103 回答