From 0fa498e98bbcbc026a5fc658bc40ab2ec154b0ed Mon Sep 17 00:00:00 2001 From: Shay Date: Thu, 14 May 2026 13:44:09 -0700 Subject: [PATCH] =?UTF-8?q?fix(surface):=20add=20empty-slot=20guard=20?= =?UTF-8?q?=E2=80=94=20fallback=20when=20subject+predicate=20both=20empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add fallback mechanism for empty subject and predicate in surface generation. --- generate/surface.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/generate/surface.py b/generate/surface.py index 593e4e11..34807ea1 100644 --- a/generate/surface.py +++ b/generate/surface.py @@ -256,11 +256,27 @@ class SentenceAssembler: if w ) elab_tokens = _elaboration_tokens(tokens, used_slots) + + # Empty-slot guard: if slot versors were missing, both subject and + # predicate will be empty. Fall back to the raw articulation surface + # rather than emitting a bare ".". + if not subject and not predicate: + fallback = plan.surface or " ".join(t for t in tokens if t) + return SentencePlan( + subject="", + predicate_phrase="", + object_phrase=object_, + elaboration=None, + dialogue_role=role_str, + output_language=lang, + surface=fallback, + ) # Language dispatch if lang == "he": surface = _assemble_he(subject, predicate, object_, elab_tokens, role_str) - elif lang == "grc": + +elif lang == "grc": surface = _assemble_grc(subject, predicate, object_, elab_tokens, role_str) else: surface = _assemble_en(subject, predicate, object_, elab_tokens, role_str)