Skip to content

Add optional argument so nltk files can be downloaded in a specific directory #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions textblob/download_corpora.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
$ python -m textblob.download_corpora lite

"""
import os
import sys
import nltk

Expand All @@ -29,21 +30,23 @@

ALL_CORPORA = MIN_CORPORA + ADDITIONAL_CORPORA

def download_lite():

def download_lite(download_dir=None):
for each in MIN_CORPORA:
nltk.download(each)
nltk.download(each, download_dir=download_dir)


def download_all():
def download_all(download_dir=None):
for each in ALL_CORPORA:
nltk.download(each)
nltk.download(each, download_dir=download_dir)


def main():
download_dir = os.getenv('NLTK_DATA')
if 'lite' in sys.argv:
download_lite()
download_lite(download_dir)
else:
download_all()
download_all(download_dir)
print("Finished.")


Expand Down