fix(surface): add empty-slot guard — fallback when subject+predicate both empty

Add fallback mechanism for empty subject and predicate in surface generation.
This commit is contained in:
Shay 2026-05-14 13:44:09 -07:00 committed by GitHub
parent bab4790c10
commit 0fa498e98b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)