首页 > 解决方案 > Chatterbot 提供 SpaCy 密钥错误/适配器问题

问题描述

我正在尝试开发一个可以响应“匹配”类型输入以及计算和时间输入的聊天机器人。运行跟随脚本时


from chatterbot import ChatBot

bot = ChatBot(
'Maxine',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
'chatterbot.logic.BestMatch',
'chatterbot.logic.MathematicalEvaluation',
'chatterbot.logic.TimeLogicAdapter'
],
database_uri='sqlite:///database.sqlite3'
)

print('ask me something')
while True:
try:
bot_input = bot.get_response(input())
print(bot_input)

except(KeyboardInterrupt, EOFError, SystemExit):
    break

获得以下回复

ask me something
how are you
I am good.

这是正确的但是:

2 + 2 是多少


Traceback (most recent call last):
File "maxine.py", line 17, in 
bot_input = bot.get_response(input())
File "/home/pi/.virtualenvs/chatterbot/lib/python3.7/site-packages/chatterbot/chatterbot.py", line 114, in get_response
response = self.generate_response(input_statement, additional_response_selection_parameters)
File "/home/pi/.virtualenvs/chatterbot/lib/python3.7/site-packages/chatterbot/chatterbot.py", line 150, in generate_response
output = adapter.process(input_statement, additional_response_selection_parameters)
File "/home/pi/.virtualenvs/chatterbot/lib/python3.7/site-packages/chatterbot/logic/best_match.py", line 61, in process
input_statement.text
File "/home/pi/.virtualenvs/chatterbot/lib/python3.7/site-packages/chatterbot/tagging.py", line 45, in get_bigram_pair_string
tokens[index].lemma_.lower()
File "token.pyx", line 894, in spacy.tokens.token.Token.lemma_.get
File "strings.pyx", line 136, in spacy.strings.StringStore.getitem
KeyError: "[E018] Can't retrieve string for hash '471611514'. This usually refers to an issue with the Vocab or StringStore."


`I am running this on a RPi4 with this version of SpaCy
spaCy version 2.3.2
Location /home/pi/.virtualenvs/chatterbot/lib/python3.7/site-packages/spacy
Platform Linux-5.4.51-v7l+-armv7l-with-debian-10.4
Python version 3.7.3
Models en

此外,如果我注释掉 BestMatch Adapter 我得到:


python maxine.py
ask me something
how much is 2 + 2
2 + 2 = 4
what time is it
The current time is 05:02 PM
how are you
The current time is 05:02 PM

这似乎意味着 bestMatch 优先于其他适配器

标签: pythonspacychatterbot

解决方案


我将架构更改为 arm64,它现在似乎可以工作了。顺便说一句,仍然需要使用 BLIS_ARCH="generic" pip3 install --user spacy --no-binary=blis 安装 spacy


推荐阅读