concept
Generated title constraint checks
A narrow lexical contract for toy title generation; does not establish truth or semantic equivalence. Use independently reviewed facts and additional evaluation for real outputs.
Formal Syntax & Structure
artificial-intelligence syntaxartificial-intelligence
length_ok and not missing and not unexpectedWorking Example
Example Snippetartificial-intelligence
def title_report(title, allowed, required, max_words): words = title.lower().split() tokens = set(words) return { "length_ok": 0 < len(words) <= max_words, "missing": sorted(set(required) - tokens), "unexpected": sorted(tokens - set(allowed)), }
allowed = ["spring", "seed", "guide", "soil"]print(title_report("Spring seed guide", allowed, ["seed"], 3))print(title_report("Free seed guarantee", allowed, ["seed"], 3))