"""Enhanced glossary models with rich metadata for theological terms.""" from __future__ import annotations from enum import Enum from pydantic import BaseModel, Field class TheologicalDomain(str, Enum): """Domain categories for theological terms.""" CHRISTOLOGY = "christology" # Study of Christ SOTERIOLOGY = "soteriology" # Study of salvation ESCHATOLOGY = "eschatology" # Study of end times PNEUMATOLOGY = "pneumatology" # Study of the Spirit ECCLESIOLOGY = "ecclesiology" # Study of the church HAMARTIOLOGY = "hamartiology" # Study of sin THEOLOGY_PROPER = "theology_proper" # Study of God ANTHROPOLOGY = "anthropology" # Study of humanity GENERAL = "general" # General theological terms class EnhancedGlossaryTerm(BaseModel): """A theological term with rich metadata for consistent translation guidance. This model is backward compatible with the original GlossaryTerm, adding optional fields for enhanced functionality. """ # Core fields (backward compatible with GlossaryTerm) original: str = Field(..., description="Original Greek/Hebrew term") transliteration: str = Field(..., description="Romanized form") japanese: str = Field(..., description="Standard Japanese translation") english: str = Field(..., description="English equivalent") notes: str | None = Field(None, description="Usage notes or context") # Morphological fields for inflection matching lemma: str | None = Field( None, description="Dictionary form (lemma) of the term for morphological matching", ) inflected_forms: list[str] = Field( default_factory=list, description="Known inflected forms of this term (e.g., conjugations, declensions)", ) strongs_number: str | None = Field( None, description="Strong's Concordance number (e.g., 'G3056' for logos)", ) # Enhanced fields definition: str | None = Field( None, description="Detailed definition of the term" ) semantic_range: list[str] = Field( default_factory=list, description="Possible meanings and nuances of the term", ) domain: TheologicalDomain = Field( default=TheologicalDomain.GENERAL, description="Theological domain this term belongs to", ) usage_examples: list[str] = Field( default_factory=list, description="Example verses or usages", ) frequency: int = Field( default=0, ge=0, description="Frequency of occurrence in the source text", ) related_terms: list[str] = Field( default_factory=list, description="Cross-references to related terms by their original form", ) avoid_translations: list[str] = Field( default_factory=list, description="Japanese translations to avoid for this term", ) def has_enhanced_metadata(self) -> bool: """Check if this term has any enhanced metadata beyond the core fields.""" return bool( self.definition or self.semantic_range or self.domain != TheologicalDomain.GENERAL or self.usage_examples or self.frequency > 0 or self.related_terms or self.avoid_translations ) def get_all_matchable_forms(self) -> list[str]: """Get all forms that can be used for matching (original, lemma, inflections). Returns: List of all matchable string forms. """ forms = [self.original] if self.lemma and self.lemma != self.original: forms.append(self.lemma) forms.extend(self.inflected_forms) return forms # Type alias for backward compatibility GlossaryTerm = EnhancedGlossaryTerm