02 Sep 2020

Chatterbot-Installation unter FreeBSD 12

Unter FreeBSD ist die Installation des Chatterbots ein wenig diffiziler. Man kriegst aber trotzdem hin. Ein Installationsprotokoll.


Als Test-Program für die Installation wird charlie.py verwendet. Es wird Python 3.7 verwenden, das unter /usr/local/bin zu finden ist


Die Dokumentation ist hier zu finden: https://chatterbot.readthedocs.io/en/stable/examples.html#simple-example


Test-Programm charlie.py

#!/usr/local/bin/python3.7
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

# Create a new chat bot named Charlie
chatbot = ChatBot('Charlie')

trainer = ListTrainer(chatbot)

trainer.train([
    "Hi, can I help you?",
    "Sure, I'd like to book a flight to Iceland.",
    "Your flight has been booked."
])

# Get a response to the input text 'I would like to book a flight.'
response = chatbot.get_response('I would like to book a flight.')

print(response)


System-Information

root@copperjail:~ # which python
/usr/local/bin/python
root@copperjail:~ # /usr/local/bin/python --version
Python 3.7.6


Installieren der Python-Binärpakete als root

root@copperjail:~ # pkg update -f
root@copperjail:~ # pkg install py32-pip
root@copperjail:~ # pkg install py37-sqlite3
root@copperjail:~ # ln -s /usr/local/bin/python3.7 /usr/local/bin/python
root@copperjail:~ # exit


Installation der pip-Pakete als User

[chrissie@copperjail ~]$ pip install --user chatterbot
Collecting chatterbot
[...]
Installing build dependencies ...
[...]
[chrissie@copperjail ~]$ fetch https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.1/en_core_web_sm-2.3.1.tar.gz
[chrissie@copperjail ~]$ pip install --user en_core_web_sm-2.3.1.tar.gz
[...]
 Successfully built spacy
[...]


Requirements

Diese Meldung kann ignoriert werden, es funktioniert trotzdem!

ERROR: chatterbot 1.1.0 has requirement spacy<2.2,>=2.1, but you'll have spacy 2.3.2 which is incompatible.


Spacy Paket auf default en linken

[chrissie@copperjail ~]$ python -m spacy link en_core_web_sm en
... Linking successful
/home/chrissie/.local/lib/python3.7/site-packages/en_core_web_sm -->
/home/chrissie/.local/lib/python3.7/site-packages/spacy/data/en
You can now load the model via spacy.load('en')


Test von Charly.py

chrissie@fehmarn ~ $ ./charlie.py 
List Trainer: [####################] 100%
Your flight has been booked

Cheers!