ChatterBotを使ってみる。


概要

Chatbotをさわってみたかったので、以下のgithubの「ChatterBot」というのをさわってみた。
まだ、入り口の入り口だが。。。エラー等に出会ったので、その対処含め、記事にする。

環境

Windows10
python3.7

エラーとその対処方法

エラーの内容

以下のようなエラーが出ることがあると思う。

    raise IOError(Errors.E941.format(name=name, full=OLD_MODEL_SHORTCUTS[name]))
OSError: [E941] Can't find model 'en'. It looks like you're trying to load a model from a shortcut, which is deprecated as of spaCy v3.0. To load the model, use its full name instead:

nlp = spacy.load("en_core_web_sm")

For more details on the available models, see the models directory: https://spacy.io/models. If you want to create a blank model, use spacy.blank: nlp = spacy.blank("en")

対処方法

に書かれているとおり、

以下の1行をReplace(置換える)

self.nlp = spacy.load(self.language.ISO_639_1.lower())

with(↓の4行へ)

if self.language.ISO_639_1.lower() == 'en':
    self.nlp = spacy.load('en_core_web_sm')
else:
    self.nlp = spacy.load(self.language.ISO_639_1.lower())

動作例

まだ、何もできませんが。。。「terminal_example.py」を動かした。

Type something to begin...

4 + 9 #入力してみた
4 + 9 = 13 #応答。天才!!!

hello! #更に、入力してみた
The current time is 10:43 AM #会話成立

sin(10) #更に、入力してみた。
( 10 ) = 10 # ??

tomorrow #時間に詳しそうなので、明日と入力してみた
The current time is 10:44 AM #無視!!!!

今後

使ってみる予定。