From 2a64e672d6e8d82436a17711f129ca093d886bc1 Mon Sep 17 00:00:00 2001 From: Jelte van Boheemen Date: Thu, 16 May 2024 16:59:18 +0200 Subject: [PATCH] Ensure no empty mappings are passed in chat enrich --- backend/annotations/writers/saf_chat.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/annotations/writers/saf_chat.py b/backend/annotations/writers/saf_chat.py index 1bae72a1..f4f65aa0 100644 --- a/backend/annotations/writers/saf_chat.py +++ b/backend/annotations/writers/saf_chat.py @@ -19,7 +19,9 @@ def _items_by_utt_word(exactresults: ExactResultsDict, items_mapping: Dict) -> D for (qid, _), hits in results.items(): for (utt_id, wordno) in hits: - out[utt_id][wordno].append(items_mapping.get(qid)) + mapped = items_mapping.get(qid) + if mapped: + out[utt_id][wordno].append(mapped) return out @@ -38,7 +40,6 @@ def find_doc_line_xsid(lines: List[ChatLine], xsid: int) -> ChatLine: return None - def enrich_chat(transcript: Transcript, allresults: AllResults, method: AssessmentMethod) -> ChatDocument: