Skip to content

Commit

Permalink
worker.py aktualisieren
Browse files Browse the repository at this point in the history
Use classification fields for mappings and tags if needed
  • Loading branch information
DrRSatzteil authored Jan 11, 2024
1 parent 8d36960 commit 460f3a7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mayanmindee/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,10 @@ def process_custom(document_id: int, document_type: str, synchronous: False) ->
)

for field_name, metadata_mappings in required_fields.items():
result = parsed_doc.document.inference.prediction.fields[field_name].contents_string()
try:
result = parsed_doc.document.inference.prediction.fields[field_name].contents_string()
except:
parsed_doc.document.inference.prediction.classifications[field_name].contents_string()
for metadata_mapping in metadata_mappings:
if "postprocess" in metadata_mapping[1]:
result = post_processing(
Expand All @@ -292,7 +295,10 @@ def process_custom(document_id: int, document_type: str, synchronous: False) ->
)

for field_name, tag_mappings in required_fields.items():
result = parsed_doc.document.inference.prediction.fields[field_name].contents_string()
try:
result = parsed_doc.document.inference.prediction.fields[field_name].contents_string()
except:
parsed_doc.document.inference.prediction.classifications[field_name].contents_string()
if result:
for tag_mapping in tag_mappings:
if is_similar(
Expand Down

0 comments on commit 460f3a7

Please sign in to comment.