python - 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 优先于其他适配器
解决方案
我将架构更改为 arm64,它现在似乎可以工作了。顺便说一句,仍然需要使用 BLIS_ARCH="generic" pip3 install --user spacy --no-binary=blis 安装 spacy
推荐阅读
- android - 将 admob 原生广告添加到回收站视图后,Android 获得正确的项目位置
- python - 如何使用 Python Cryptography 在没有后端(或使用什么后端)的情况下加载 der 证书
- java - Java SSHJ 库和启用日志记录
- mysql - SQL查询日期时间选择24小时前
- c - 在 C 中为多个变量定义条件时出现问题
- uwp - 如何防止我的 UWP 应用全屏显示?
- r - 根据时间间隔组合行值
- java - Eclipse 看不到 java 文件属性
- discord.py - 找不到命令时如何发送消息?
- python - Matplotlib Stackplot 按组计数