aegean.translate¶
translate ¶
Hybrid translation: lexicon/morphology grounding → LLM.
Builds grounding evidence from the package's own tooling (deterministic Greek
morphology and dependency syntax, optionally gated content-word LSJ glosses;
Linear A sign→sound transliteration), then hands the text plus that evidence to
aegean.ai.translate. The grounding step is deterministic and local; the
translation itself is generative and returned as an exploratory, provenanced
ExploratoryResult.
Greek grounding has several modes (see grounding_for). The default,
"morphology", grounds the model in deterministic morphology and syntax (lemma,
part of speech, case/voice/tense, and a clause skeleton from the dependency parse)
and adds no dictionary glosses: morphology, voice, case-role, and syntactic structure
are facts the toolkit computes reliably and that a model can use directly. It also adds a
gloss of any idiom present (ai.idiom_glosses): a non-compositional multiword
expression is the one error class per-token morphology cannot reach, since the words'
lemmas and case only reinforce the wrong literal reading, and the curated idiom lexicon
matches deterministically with a low false-positive rate, so it rides with the safe
default. "full" keeps those morphology and idiom lines and adds a gloss layer in the
configuration that helps rather than hurts: glosses sourced from a concise,
common-sense-first dictionary cascade (Middle Liddell, Cunliffe for Homer, Abbott-Smith /
Dodson for the NT), cleaned, and gated to the text's rare content words (see
ai.grounding.content_glosses with source="cascade").
That source matters: a first-sense gloss from the historical LSJ lexicon is often the
archaic meaning (καιρός, βίος), so asserting it injects errors, whereas a concise dictionary
leads with the common sense and helps most exactly on the rare vocabulary a model is likely
to miss. "none" adds no grounding.
The older "lemma" mode (lemma lines plus gated content-word LSJ glosses) is retained
unchanged for back-compatibility; its glosses are the deliberately selective LSJ ones (see
ai.grounding.content_glosses with the default source="lsj"): only low-polysemy content
words, where the dominant-sense gloss is reliable, leaving highly polysemous words to the
model.
grounding_for ¶
grounding_for(text: str, script: str, *, mode: GroundingMode = 'morphology', glosses: bool = True) -> list[GroundingItem]
Local, deterministic grounding evidence for text in script — each item
tagged with its source (analysis:morphology / analysis:syntax /
analysis:rarity / lexicon:idiom / lemmatizer / lexicon:LSJ /
transliteration) so the result's trace() shows where the grounding came from.
For greek, mode selects the grounding style:
"morphology"(default, recommended): deterministic morphology and syntax — a per-token line (lemma, part of speech, case/voice/tense) plus a clause skeleton (main predicate, subject, object) from the dependency parse, and a rare-word flag. No dictionary glosses, but it does include a gloss of any idiom present (a curated, non-compositional multiword expression matched on surface/lemma; sourcelexicon:idiom). Morphology, voice, case-role, and structure are facts the toolkit computes reliably and a model can use directly; an auto-selected dictionary gloss can surface the wrong or an archaic sense and mislead the model, so this mode omits those. An idiom gloss is different: the phrase is non-compositional, so the literal token reading is itself the error, and the lexicon match is deterministic and low-false-positive, which is why it rides with the default."full": the"morphology"lines (including idiom glosses) and a gloss layer in the configuration that helps. Glosses come from a concise, common-sense-first dictionary cascade (Middle Liddell, Cunliffe for Homer, Abbott-Smith / Dodson for the NT), cleaned, and gated to the rare content words. Not LSJ-first-sense: that historical lexicon orders senses etymologically, so its lead sense is often the archaic meaning and asserting it injects errors; a concise dictionary leads with the common sense and helps most on the rare vocabulary a model is likely to miss. Source taglexicon:concise. Best-effort: the glosses are simply absent if no concise dictionary is loaded (greek.use_lexicon("middle-liddell")etc.)."lemma": the lemma-line grounding plus gated content-word LSJ glosses (the prior default; retained unchanged for back-compatibility). Source taglexicon:LSJ."none": no grounding.
Any other mode raises ValueError naming the valid modes (a typo must not
silently change the grounding style).
glosses is retained for back-compatibility and is superseded by mode:
it only affects the gloss-bearing modes ("lemma", "full"), where
glosses=False drops the glosses (lemma-only / morphology-only). It has no effect
on "morphology" (already gloss-free) or "none".
The "morphology" grounding uses the active backends (greek.pipeline(text,
parse=True)): with use_neural_pipeline active it carries gold morphology and a UD
parse; without it, rule-based POS and lemmas still populate the token lines and the
clause skeleton is simply omitted. It never raises.
translate ¶
translate(text: str, *, script: str = 'greek', target: str = 'English', mode: GroundingMode = 'morphology', glosses: bool = True, verify: bool = False, client: LLMClient | None = None) -> ExploratoryResult
Translate text (a greek or lineara string) into target,
grounded in locally-derived morphology/lexicon/transliteration evidence.
Exploratory: the grounding is real, the translation is a model hypothesis — especially for undeciphered Linear A.
For greek, mode (default "morphology") selects the grounding style; see
grounding_for. The default grounds the model in deterministic morphology and
syntax (lemma, part of speech, case/voice/tense, clause skeleton) plus a gloss of any
non-compositional idiom present (ai.idiom_glosses), with no dictionary glosses
on ordinary words. Use mode="full" to add, on top of those morphology lines, a
gloss layer sourced from a concise, common-sense-first dictionary cascade (Middle
Liddell, Cunliffe, Abbott-Smith / Dodson), cleaned and gated to the rare content words:
a concise dictionary leads with the common sense and helps most on rare vocabulary,
whereas an LSJ-first-sense gloss is often the archaic meaning and misleads. Use
mode="lemma" for the older lemma-line plus gated LSJ-gloss grounding, or
mode="none" for no grounding. An unrecognized mode raises ValueError
naming the valid modes.
glosses is retained for back-compatibility and is superseded by mode: it only
affects the gloss-bearing modes ("lemma", "full"), where glosses=False
drops the glosses.
verify (Greek only) runs a translate-then-check-and-repair pass instead of a
single grounded call. The text is first translated raw, with no grounding in the
prompt, so the local analysis cannot bias the draft. The full grounding (morphology,
idiom glosses, and concise glosses, as for mode="full") is then supplied to a
second call that checks the draft against it and corrects only definite contradictions
(wrong voice, subject or object, case relation, a rare word's or idiom's sense, an
omission or addition), keeping the draft where it is already right. Because the
grounding only ever reaches the checker, it cannot bias the initial draft; a wrong
analysis can still mislead the repair step, so the pass is only as sound as the
grounding it checks against. This reduces definite errors, most on hard text, at the
cost of a second model call, so it is worth reaching for on hard or high-stakes
passages and skipping on routine ones. It supersedes mode for Greek (the checker
always sees the full grounding); for non-Greek scripts it has no effect and the
normal single call is used.
Coverage of rare or inflected forms (and the clause skeleton) depends on the active
backends, so a warning is raised when only the baseline seed table is loaded (call
aegean.greek.use_treebank(), or use_neural_pipeline() for gold morphology and a
UD parse, first).