From 2c442a373858b93f21b9cdb78e549e3f74a5b643 Mon Sep 17 00:00:00 2001 From: Charles Connell Date: Thu, 1 May 2014 15:13:59 -0400 Subject: [PATCH] Move NLTK download to management command --- fabfile.py | 3 +-- .../quizzes/management/commands/nltk_download.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 karmaworld/apps/quizzes/management/commands/nltk_download.py diff --git a/fabfile.py b/fabfile.py index 460dfa6..8ce4315 100644 --- a/fabfile.py +++ b/fabfile.py @@ -292,8 +292,7 @@ def nltk_download(): """ Initialize corpa used by NLTK """ - virtenv_exec('python -c "import nltk\n' - 'nltk.download(\'maxent_treebank_pos_tagger\')'"") + virtenv_exec('{0}/manage.py nltk_download'.format(env.code_root)) @task def first_deploy(): diff --git a/karmaworld/apps/quizzes/management/commands/nltk_download.py b/karmaworld/apps/quizzes/management/commands/nltk_download.py new file mode 100644 index 0000000..925ed65 --- /dev/null +++ b/karmaworld/apps/quizzes/management/commands/nltk_download.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python2 +from django.core.management import BaseCommand + +import nltk + + +class Command(BaseCommand): + help = "Download the data needed for the Natural Language Toolkit to find note keywords." + + def handle(self, *args, **kwargs): + nltk.download('punkt') + nltk.download('maxent_treebank_pos_tagger') + nltk.download('stopwords') + -- 2.25.1