From: Charles Connell Date: Thu, 1 May 2014 19:13:59 +0000 (-0400) Subject: Move NLTK download to management command X-Git-Tag: release-20150131~100 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2c442a373858b93f21b9cdb78e549e3f74a5b643;p=oweals%2Fkarmaworld.git Move NLTK download to management command --- 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') +