File size: 1,146 Bytes
ed6bec6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
from typing import List
from .glyph_dictionary_loader import get_dictionary
class GlyphValidationError(Exception):
pass
def validate_glyph(glyph: str) -> None:
dictionary = get_dictionary()
entries = dictionary.get_entry_by_glyph(glyph)
if not entries:
raise GlyphValidationError(f"Unknown glyph: {glyph}")
def validate_sequence(glyphs: List[str]) -> None:
if not glyphs:
raise GlyphValidationError("Empty glyph sequence.")
for g in glyphs:
validate_glyph(g)
def validate_roles(glyphs: List[str]) -> None:
"""
Minimal role validation prototype:
- Ensure at least one non-context role exists (e.g., object/action/actor)
"""
dictionary = get_dictionary()
has_core_role = False
for g in glyphs:
entries = dictionary.get_entry_by_glyph(g) or []
for e in entries:
roles = e.get("roles", [])
if any(r in roles for r in ["object", "action", "actor"]):
has_core_role = True
break
if not has_core_role:
raise GlyphValidationError("Sequence has no core roles (object/action/actor).")
|