如何解决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适配器,我也会得到:
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优先于其他适配器
解决方法
我将体系结构更改为arm64,现在似乎可以正常工作了。 BTW仍需要使用安装spacy BLIS_ARCH =“ generic” pip3 install --user spacy --no-binary = blis
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。