"""Global coherence checks for ALAN language and test."""
from __future__ import annotations
from typing import Dict, Any
from language_spec import generate_language_instance, FEMININE_NOUNS
def check_lexicon(spec) -> bool:
# ensure stems don't start with markers
markers = ("na", "mem", "leko")
for stem in spec.lexicon["nouns"].values():
if stem.startswith(markers):
return False
return True
def check_rules(meta: Dict[str, Any]) -> bool:
required = {
"Word order: DOER RECEIVER VERB (SOV). For 'give': doer, recipient, theme, verb.",
"Prefix stacking: na (receiver) + mem (feminine) + leko (plural) + noun; doer adds suffix mur.",
"Irregulars: verb 'ror' past = 'rontmimu'; plural of 'tul' = 'letul'.",
}
return required.issubset(set(meta.get("rules", [])))
def check_coherence(data: Dict[str, Any]) -> bool:
spec = generate_language_instance()
if not check_lexicon(spec):
return False
if not check_rules(data.get("meta", {})):
return False
return True