Files
subtitle_translator/domain_models.py
2025-12-14 19:00:23 +03:00

37 lines
1.5 KiB
Python

# [DEF:domain_models:Module]
# @SEMANTICS: data_structures, schemas, pydantic, context_definition
# @PURPOSE: Define strict schemas for Context and Subtitle entities.
# @LAYER: Domain
# @RELATION: READS_FROM -> None
# @PUBLIC_API: TranslationContext, CharacterProfile, SubtitleLine
from typing import List, Dict, Optional
from pydantic import BaseModel, Field
# [DEF:TranslationContext:DataClass]
# @PURPOSE: Holds the semantic snapshot of the entire plot (Result of Pass 1)
class CharacterProfile(BaseModel):
name: str = Field(..., description="Character name or 'Unknown'")
role: str = Field(..., description="Role in the story")
speech_style: str = Field(..., description="Formal, slang, archaic, etc.")
class TranslationContext(BaseModel):
title: str = Field(..., description="Inferred title or topic")
genre: str = Field(..., description="Genre and atmosphere")
plot_summary: str = Field(..., description="Brief summary of the content")
style_guidelines: str = Field(..., description="Instructions for the translator (tone, register)")
terminology: Dict[str, str] = Field(default_factory=dict, description="Key terms glossary")
characters: List[CharacterProfile] = Field(default_factory=list)
# [/DEF:TranslationContext]
# [DEF:SubtitleLine:DataClass]
# @PURPOSE: Atomic unit of subtitle
class SubtitleLine(BaseModel):
index: int
start_time: str
end_time: str
original_text: str
translated_text: Optional[str] = None
# [/DEF:SubtitleLine]
# [/DEF:domain_models]