gunthercox / ChatterBot

ChatterBot is a machine learning, conversational dialog engine for creating chat bots
https://chatterbot.readthedocs.io
BSD 3-Clause "New" or "Revised" License
14.1k stars 4.45k forks source link

Run nltk.data quietly #1975

Closed psychemedia closed 4 years ago

psychemedia commented 4 years ago

Creating a new chatterbot in a Jupyter notebook code cell as:

from chatterbot import ChatBot
chatbot = ChatBot("Test")

results in nltk commentating on its own behaviour by displaying:

[nltk_data] Downloading package averaged_perceptron_tagger to
[nltk_data]     /home/jovyan/nltk_data...
[nltk_data]   Unzipping taggers/averaged_perceptron_tagger.zip.
[nltk_data] Downloading package punkt to /home/jovyan/nltk_data...
[nltk_data]   Unzipping tokenizers/punkt.zip.
[nltk_data] Downloading package stopwords to /home/jovyan/nltk_data...
[nltk_data]   Unzipping corpora/stopwords.zip.
[nltk_data] Downloading package wordnet to /home/jovyan/nltk_data...
[nltk_data]   Unzipping corpora/wordnet.zip.

as cell output. IPyhton %%capture magic is unsuccessful at suppressing this, as is trying to suppress warnings and logging.

It would be useful if nltk,data could be run with quiet=True setting, or allow quiet=True to be passed through, eg via ChatBot("Test", quiet=True)`

psychemedia commented 4 years ago

To answer my own issue, one way to mitigate this is to clear the cell output explicitly:

from chatterbot import ChatBot
chatbot = ChatBot("Test")

# Clear the nltk output
from IPython.display import clear_output
clear_output()