Move NLTK download to management command
authorCharles Connell <charles@connells.org>
Thu, 1 May 2014 19:13:59 +0000 (15:13 -0400)
committerCharles Connell <charles@connells.org>
Thu, 1 May 2014 19:13:59 +0000 (15:13 -0400)
fabfile.py
karmaworld/apps/quizzes/management/commands/nltk_download.py [new file with mode: 0644]

index 460dfa65ed153a28aa9dc09070f1f987bf9dae64..8ce43151258839e36c67733bf75c09b01c4f08b0 100644 (file)
@@ -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 (file)
index 0000000..925ed65
--- /dev/null
@@ -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')
+