Pre-publication review draft
日常訳NICHIJOYAKU日本語 ↗

OPEN SOURCE

software/src/models/verse.py

Read on this site and download the files you need.

Nichijoyaku was created using AI. A complete review by human biblical-language and biblical-studies specialists has not been established. Read alongside established translations and original-language resources.

← Back to the open-source guide

software/src/models/verse.py127 linesDownload this file ↓

This is the same source included in the download. Each line number is a link you can save or share.

File verification detailsSHA-256 0368c8eb90c09704c2bd59d1f1d02a8085032915f601d25e03428dc4f3a97ae0
1"""Data models for Bible verses and translation context."""23from __future__ import annotations45from datetime import datetime6from typing import TYPE_CHECKING78from pydantic import BaseModel, Field910# Import enhanced glossary for backward compatibility11from src.models.glossary import EnhancedGlossaryTerm, GlossaryTerm, TheologicalDomain1213if TYPE_CHECKING:14    pass1516# Re-export for backward compatibility17__all__ = [18    "VerseReference",19    "Verse",20    "GlossaryTerm",21    "EnhancedGlossaryTerm",22    "TheologicalDomain",23    "BookMetadata",24    "ChapterSummary",25    "TranslationContext",26    "TranslationOutput",27]282930class VerseReference(BaseModel):31    """Reference to a specific Bible verse."""3233    book: str = Field(..., description="Book name (e.g., 'john', 'genesis')")34    chapter: int = Field(..., ge=1, description="Chapter number")35    verse: int = Field(..., ge=1, description="Verse number")3637    def __str__(self) -> str:38        return f"{self.book}:{self.chapter}:{self.verse}"3940    @classmethod41    def from_string(cls, ref: str) -> VerseReference:42        """Parse a verse reference string like 'john:1:1'."""43        parts = ref.lower().split(":")44        if len(parts) != 3:45            msg = f"Invalid verse reference: {ref}. Expected format: 'book:chapter:verse'"46            raise ValueError(msg)47        return cls(book=parts[0], chapter=int(parts[1]), verse=int(parts[2]))484950class Verse(BaseModel):51    """A Bible verse with source texts from multiple translations."""5253    reference: VerseReference54    greek_text: str | None = Field(None, description="Greek source text (NT only)")55    greek_translit: str | None = Field(None, description="Greek transliteration")56    hebrew_text: str | None = Field(None, description="Hebrew source text (OT only)")57    hebrew_translit: str | None = Field(None, description="Hebrew transliteration")58    japanese_meiji: str | None = Field(None, description="Meiji translation (1887)")59    japanese_taisho: str | None = Field(None, description="Taisho translation (1917)")60    japanese_kougo: str | None = Field(None, description="Kougo translation (1955)")61    greek_words: list[dict] | None = Field(None, description="MorphGNT word entries")62    hebrew_words: list[dict] | None = Field(None, description="OSHB word entries")63    english_kjv: str | None = Field(None, description="King James Version")64    english_asv: str | None = Field(None, description="American Standard Version")6566    def has_source_text(self) -> bool:67        """Check if the verse has at least one source text."""68        return bool(self.greek_text or self.hebrew_text)697071class BookMetadata(BaseModel):72    """Metadata about a Bible book."""7374    book: str = Field(..., description="Book name (e.g., 'john')")75    name_japanese: str = Field(..., description="Japanese book name")76    name_english: str = Field(..., description="English book name")77    testament: str = Field(..., description="'OT' or 'NT'")78    author: str = Field(..., description="Traditional author attribution")79    themes: list[str] = Field(default_factory=list, description="Key themes")80    description: str = Field(..., description="Brief description of the book")81    chapter_count: int = Field(..., ge=1, description="Total number of chapters")82    verse_count: int = Field(..., ge=1, description="Total number of verses")838485class ChapterSummary(BaseModel):86    """Summary of a Bible chapter for context."""8788    book: str89    chapter: int90    summary: str = Field(..., description="Brief chapter summary")91    key_events: list[str] = Field(default_factory=list)92    key_characters: list[str] = Field(default_factory=list)93    key_themes: list[str] = Field(default_factory=list)949596class TranslationContext(BaseModel):97    """Full context for translating a verse."""9899    target_verse: Verse100    preceding_verses: list[Verse] = Field(default_factory=list)101    following_verses: list[Verse] = Field(default_factory=list)102    chapter_summary: ChapterSummary | None = None103    book_metadata: BookMetadata | None = None104    glossary_terms: list[GlossaryTerm] = Field(default_factory=list)105106107class TranslationOutput(BaseModel):108    """Output from a translation operation."""109110    reference: VerseReference111    text: str = Field(..., description="Plain Japanese text (furigana stripped)")112    text_with_furigana: str = Field(113        default="", description="Text with inline furigana notation"114    )115    furigana_annotations: list[dict] = Field(116        default_factory=list, description="Serialized FuriganaAnnotation list"117    )118    model: str = Field(..., description="Model used for translation")119    timestamp: datetime = Field(default_factory=datetime.utcnow)120    prompt_version: str = Field(default="v1.0")121    sources_used: list[str] = Field(122        default_factory=list, description="Source texts used"123    )124    glossary_terms_applied: list[str] = Field(125        default_factory=list, description="Glossary terms applied"126    )127