the document classifier is now stateless

This commit is contained in:
Jonas Winkler
2020-10-29 14:33:42 +01:00
parent 3e50e51b8a
commit 05f20c19c3
4 changed files with 12 additions and 19 deletions

View File

@@ -7,7 +7,7 @@ from documents.models import MatchingModel, Correspondent, DocumentType, Tag
def match_correspondents(document_content, classifier):
correspondents = Correspondent.objects.all()
predicted_correspondent_id = classifier.predict_correspondent() if classifier else None
predicted_correspondent_id = classifier.predict_correspondent(document_content) if classifier else None
matched_correspondents = [o for o in correspondents if matches(o, document_content) or o.id == predicted_correspondent_id]
return matched_correspondents
@@ -15,7 +15,7 @@ def match_correspondents(document_content, classifier):
def match_document_types(document_content, classifier):
document_types = DocumentType.objects.all()
predicted_document_type_id = classifier.predict_document_type() if classifier else None
predicted_document_type_id = classifier.predict_document_type(document_content) if classifier else None
matched_document_types = [o for o in document_types if matches(o, document_content) or o.id == predicted_document_type_id]
return matched_document_types
@@ -23,7 +23,7 @@ def match_document_types(document_content, classifier):
def match_tags(document_content, classifier):
objects = Tag.objects.all()
predicted_tag_ids = classifier.predict_tags() if classifier else []
predicted_tag_ids = classifier.predict_tags(document_content) if classifier else []
matched_tags = [o for o in objects if matches(o, document_content) or o.id in predicted_tag_ids]
return matched_tags