From f6577084de4c6ac759108da8797ee228c1b12af6 Mon Sep 17 00:00:00 2001 From: Yoann Schneider <yschneider@teklia.com> Date: Fri, 13 Sep 2024 11:57:48 +0200 Subject: [PATCH] Support the case where the model can predict NER entities but doesn't in that case --- dan/ocr/predict/attention.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dan/ocr/predict/attention.py b/dan/ocr/predict/attention.py index 07b8c5cc..6d94a4d4 100644 --- a/dan/ocr/predict/attention.py +++ b/dan/ocr/predict/attention.py @@ -44,7 +44,8 @@ def compute_offsets_by_level(full_text: str, level: Level, text_list: List[str]) """ # offsets[idx] = number of characters between text_list[idx-1] and text_list[idx] offsets = [int(level != Level.Char)] * (len(text_list) - 1) - if level == Level.NER: + # Take entities into account if there are any + if level == Level.NER and text_list: # Start after the first entity cursor = len(text_list[0]) for idx, split in enumerate(text_list[1:]): -- GitLab