mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-31 10:37:12 -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): | class Command(Renderable, BaseCommand): | ||||||
| 
 | 
 | ||||||
|     help = """ |     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("    ", "") |     """.replace("    ", "") | ||||||
| 
 | 
 | ||||||
|     def __init__(self, *args, **kwargs): |     def __init__(self, *args, **kwargs): | ||||||
| @ -18,6 +19,7 @@ class Command(Renderable, BaseCommand): | |||||||
|     def handle(self, *args, **options): |     def handle(self, *args, **options): | ||||||
|         clf = DocumentClassifier() |         clf = DocumentClassifier() | ||||||
|         clf.train() |         clf.train() | ||||||
|         logging.getLogger(__name__).info("Saving models to " + |         logging.getLogger(__name__).info( | ||||||
|                                          settings.MODEL_FILE + "...") |             "Saving models to {}...".format(settings.MODEL_FILE) | ||||||
|  |         ) | ||||||
|         clf.save_classifier() |         clf.save_classifier() | ||||||
|  | |||||||
| @ -48,17 +48,28 @@ class Command(Renderable, BaseCommand): | |||||||
|         self.verbosity = options["verbosity"] |         self.verbosity = options["verbosity"] | ||||||
| 
 | 
 | ||||||
|         if options["inbox_only"]: |         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: |         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") |         logging.getLogger(__name__).info("Loading classifier") | ||||||
|         try: |         try: | ||||||
|             clf = DocumentClassifier.load_classifier() |             clf = DocumentClassifier.load_classifier() | ||||||
|         except FileNotFoundError: |         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 |             return | ||||||
| 
 | 
 | ||||||
|         for document in documents: |         for document in documents: | ||||||
|             logging.getLogger(__name__).info("Processing document {}".format(document.title)) |             logging.getLogger(__name__).info( | ||||||
|             clf.classify_document(document, classify_document_type=options["type"], classify_tags=options["tags"], classify_correspondent=options["correspondent"], replace_tags=options["replace_tags"]) |                 "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