paperless-ngx/src/documents/management/commands/document_create_classifier.py

24 lines
649 B
Python
Raw Normal View History

import logging
from django.core.management.base import BaseCommand
2018-09-13 14:15:16 +02:00
from documents.classifier import DocumentClassifier
from paperless import settings
from ...mixins import Renderable
class Command(Renderable, BaseCommand):
help = """
There is no help.
""".replace(" ", "")
def __init__(self, *args, **kwargs):
BaseCommand.__init__(self, *args, **kwargs)
def handle(self, *args, **options):
clf = DocumentClassifier()
2018-09-05 12:43:11 +02:00
clf.train()
2018-09-25 16:09:33 +02:00
logging.getLogger(__name__).info("Saving models to " +
settings.MODEL_FILE + "...")
2018-09-05 12:43:11 +02:00
clf.save_classifier()