mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-31 02:27:10 -04:00 
			
		
		
		
	Code style changes
This commit is contained in:
		
							parent
							
								
									60618381f8
								
							
						
					
					
						commit
						b31d4779bf
					
				| @ -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() | ||||
|  | ||||
| @ -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"] | ||||
|             ) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user