question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to disable nltk_data command line output?

See original GitHub issue

Hi. I’m developing a chatbot with this library. I was wondering if there’s any way to suppress the output to the command line related to nltk_data every time I run my program. I am talking about this:

[nltk_data] Downloading package averaged_perceptron_tagger to
[nltk_data]     /home/sgeor/nltk_data...
[nltk_data]   Package averaged_perceptron_tagger is already up-to-
[nltk_data]       date!
[nltk_data] Downloading package punkt to /home/sgeor/nltk_data...
[nltk_data]   Package punkt is already up-to-date!
[nltk_data] Downloading package stopwords to /home/sgeor/nltk_data...
[nltk_data]   Package stopwords is already up-to-date!

I am using flask for the frontend of my app and every time the server is restarted (or I run any of the flask do_something commands I have implemented) this appears in the console.

Thanks.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
corberancommented, Jun 13, 2019
  1. cd to C:\Users\YOUR_USER_NAME\AppData\Roaming\nltk_data or venv/nltk_data or where nltk_data is downloaded…
  2. copy nltk_data/corpora/stopwords to nltk_data/stopwords
  3. copy nltk_data/taggers/averaged_perceptron_tagger to nltk_data/averaged_perceptron_tagger

Before: image

After: image

In version 1.0.5, chatterbot/utils.py has four download_nltk_xxx functions:

def download_nltk_stopwords():
    """
    Download required NLTK stopwords corpus if it has not already been downloaded.
    """
    nltk_download_corpus('stopwords') # should be 'corpora/stopwords'


def download_nltk_wordnet():
    """
    Download required NLTK corpora if they have not already been downloaded.
    """
    nltk_download_corpus('corpora/wordnet')


def download_nltk_averaged_perceptron_tagger():
    """
    Download the NLTK averaged perceptron tagger that is required for this algorithm
    to run only if the corpora has not already been downloaded.
    """
    nltk_download_corpus('averaged_perceptron_tagger') # should be 'taggers/averaged_perceptron_tagger'


def download_nltk_vader_lexicon():
    """
    Download the NLTK vader lexicon for sentiment analysis
    that is required for this algorithm to run.
    """
    nltk_download_corpus('vader_lexicon')

They all call the function nltk_download_corpus, whose parameter resource_path represents the path to check if the data exists.

7reactions
gunthercoxcommented, Feb 17, 2019

In an upcoming release, I’d be happy to add an option that makes it possible to disable this output.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - How to stop NLTK from outputting to terminal when ...
Use quiet=True : import nltk nltk.download('wordnet', quiet=True).
Read more >
nltk.downloader
TXT """ The NLTK corpus and module downloader. This module defines several interfaces which can be used to download corpora, models, and other...
Read more >
Python & NLTK Frequently Asked Questions
Uninstall your current version of NLTK: Open up a terminal windows and type sudo pip uninstall nltk. · Install NLTK 2.0. · Verify...
Read more >
Part of Speech Tagging with Stop words using NLTK in python
There is no universal list of stop words in nlp research, however the nltk module contains a list of stop words. You can...
Read more >
How to Use the Python Natural Language Toolkit (NLTK) in ...
Download NLTK Data for all users (not recommended). Warning. This procedure needs command-line access and administrative privileges on the machine hosting ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found