diff --git a/src/documents/management/commands/document_create_classifier.py b/src/documents/management/commands/document_create_classifier.py index 79f766c55..e5adcbfa5 100755 --- a/src/documents/management/commands/document_create_classifier.py +++ b/src/documents/management/commands/document_create_classifier.py @@ -9,7 +9,8 @@ from ...mixins import Renderable class Command(Renderable, BaseCommand): help = """ - There is no help. + Trains the classifier on your data and saves the resulting models to a + file. The document consumer will then automatically use this new model. """.replace(" ", "") def __init__(self, *args, **kwargs): @@ -18,6 +19,7 @@ class Command(Renderable, BaseCommand): def handle(self, *args, **options): clf = DocumentClassifier() clf.train() - logging.getLogger(__name__).info("Saving models to " + - settings.MODEL_FILE + "...") + logging.getLogger(__name__).info( + "Saving models to {}...".format(settings.MODEL_FILE) + ) clf.save_classifier() diff --git a/src/documents/management/commands/document_retagger.py b/src/documents/management/commands/document_retagger.py index 5bc8614d6..b5853441b 100755 --- a/src/documents/management/commands/document_retagger.py +++ b/src/documents/management/commands/document_retagger.py @@ -48,17 +48,28 @@ class Command(Renderable, BaseCommand): self.verbosity = options["verbosity"] if options["inbox_only"]: - documents = Document.objects.filter(tags__is_inbox_tag=True).exclude(tags__is_archived_tag=True).distinct() + queryset = Document.objects.filter(tags__is_inbox_tag=True) else: - documents = Document.objects.all().exclude(tags__is_archived_tag=True).distinct() + queryset = Document.objects.all() + documents = queryset.exclude(tags__is_archived_tag=True).distinct() logging.getLogger(__name__).info("Loading classifier") try: clf = DocumentClassifier.load_classifier() except FileNotFoundError: - logging.getLogger(__name__).fatal("Cannot classify documents, classifier model file was not found.") + logging.getLogger(__name__).fatal("Cannot classify documents, " + "classifier model file was not " + "found.") return for document in documents: - logging.getLogger(__name__).info("Processing document {}".format(document.title)) - clf.classify_document(document, classify_document_type=options["type"], classify_tags=options["tags"], classify_correspondent=options["correspondent"], replace_tags=options["replace_tags"]) + logging.getLogger(__name__).info( + "Processing document {}".format(document.title) + ) + clf.classify_document( + document, + classify_document_type=options["type"], + classify_tags=options["tags"], + classify_correspondent=options["correspondent"], + replace_tags=options["replace_tags"] + )