Skip to main content

Dilemma

Tests

Dilemma

Dilemma finds dictionary headwords for Ancient, Medieval/Byzantine, and Modern Greek, including Katharevousa. It combines dictionary and corpus lookups, morphological rules, and a small character-level transformer for unfamiliar forms. You can use it as a Python library, with or without neural inference.

Dilemma is part of Open Greek. It uses corrected texts from the Open Greek Corpus for word frequencies and corpus attestation.

Install

Python 3.10 or newer is required. Install from PyPI, then download the data:

python3 -m pip install "dilemma-nlp[onnx]"
python3 -m dilemma download --no-tagger

The onnx extra enables inference for unseen forms. For lookup and rule-based analysis without a neural backend, install plain dilemma-nlp and use guess=False. The torch extra is an alternative if you use PyTorch.

The Python package and its data are separate downloads. The command above fetches lookup data and lemmatizer weights into ~/.cache/dilemma/; it skips POS tagger weights. The data download is several gigabytes. To include the tagger, omit --no-tagger.

Download options:

Flag Effect
--with-attestation Exact-form attestation and usage distributions
--with-citations Example passages, including the attestation data above
--dir PATH Writes downloads under a different directory

Set DILEMMA_DATA_DIR to select a particular data/ directory, and DILEMMA_MODEL_DIR to select a model/ directory. Without an override, the lemmatizer checks the download cache, a source checkout, and bundled data, using the most recently built or downloaded artifacts. A data directory that lacks a list lemmatization reads (the *_headwords.json lists, grc_lexical_heads.json, grc_adverb_heads.json, or the convention files) still loads, but Dilemma() emits a DilemmaDataWarning naming the missing files, because the lemmas then differ from those of a full download.

Lemmatize words

from dilemma import Dilemma

greek = Dilemma()

greek.lemmatize("ἀνθρώπους", guess=False)  # "ἄνθρωπος"
greek.lemmatize("ἔγραψα", guess=False)     # "γράφω"
greek.lemmatize("ἀλλ’", guess=False)       # "ἀλλά"
greek.lemmatize_batch(
    ["λέγουσι", "θεούς"], guess=False
)  # ["λέγω", "θεός"]

With guess=False, unresolved words return None, or an empty list in verbose mode. Lookup and deterministic rules still run. Tokens without Greek letters pass through unchanged.

The default, guess=True, also tries the transformer when the earlier steps cannot resolve a word. If no acceptable lemma is found, it returns the input unchanged. Use guess=False when an explicit missing result is preferable. Constructing Dilemma does not import ONNX Runtime or PyTorch; backend checks and model loading wait until inference is needed.

Choose a language and dictionary convention

Language selects the lookup tables. Convention selects the dictionary headword you want in the output.

Text Starting point
Mixed periods or Katharevousa Dilemma() — combined lookup, Wiktionary citation forms
Ancient or literary Byzantine Greek Dilemma(lang="grc")
Demotic Modern Greek Dilemma(lang="el", convention="triantafyllidis")
LSJ-based work Dilemma(lang="grc", convention="lsj")
Homeric work using Cunliffe Dilemma(lang="grc", convention="cunliffe")

The lemmatizer accepts lang="all" (the default), "grc", or "el". Vernacular medieval forms are included in el; classicizing Byzantine forms are handled by grc. Katharevousa often benefits from the combined lookup. See language coverage for the distinction between period, dialect, and lookup language.

Modern Greek lookup keeps the dialect conjunction τσαι separate from the noun τσάι. Missing active imperfect cells use source-recorded past stems, including both συλλάμβανε and συνελάμβανε; the builder does not guess past stems from present forms. An explicit noun POS tag can select τσάι while a conjunction tag retains τσαι. See the data guide for the rules, evidence, and reversible rebuild. Present/future alternatives are separate analyses; imperfective aspect does not imply imperfect past tense. Source-tag corrections record the original reading and the evidence for the change.

modern = Dilemma(lang="el", convention="triantafyllidis")
modern.lemmatize("εργαλεία", guess=False)  # "εργαλείο"

lsj = Dilemma(lang="grc", convention="lsj")
lsj.lemmatize("εἶπον", guess=False)  # "λέγω"

By default, marked Ancient articles keep their own forms: ἡ stays ἡ, and a positional grave becomes acute (τὸ → τό). Set resolve_articles=True for canonical article and pronoun lemmas such as ὁ and ἐγώ, as used in many treebanks. The triantafyllidis convention enables its Modern Greek closed-class mappings automatically. With Ancient Greek article resolution enabled, marked article forms retain their canonical lemma in both POS APIs even when the tagger labels them as nouns or proper nouns. This does not override independent pronoun readings, unmarked homographs, or the Modern Greek convention. Input attestation and rejected-target checks still apply.

Work with ambiguous or damaged text

lemmatize_verbose() returns candidate lemmas with language, source, score, and proper-name metadata. Use lemmatize_pos() or lemmatize_batch_pos() when you already have part-of-speech tags. A POS entry found only under the accent-stripped spelling does not override the reading of the form as written (ὄρους NOUN stays ὄρος). A preceding article can also help rank verbose candidates through prev_word.

Reviewed imperfect forms such as ἀπῇμεν retain the grammatical lemma ἄπειμι. Their candidate's grammar field gives the person, number, tense, voice, and mood, with ἀπέρχομαι recorded separately as a related headword. When a reviewed form belongs to several verbs, verbose mode keeps each reading. For example, ᾖσαν can come from εἶμι, οἶδα, or ἀείδω, with a different tense in each analysis. A single-answer call keeps its existing supported preference; these methods do not resolve same-POS ambiguity from sentence meaning. See verbose mode for the fields and source evidence.

For nonstandard historical spelling, enable a normalization profile:

byzantine = Dilemma(normalize=True, period="byzantine")
ionic = Dilemma(dialect="ionic")

The library also provides spelling suggestions, Ancient Greek paradigm generation, corpus attestations and example passages, and repair of corrupt lemma annotations. The API guide explains the options and their data requirements, including citation_policy="strict_ag" for independently supported Ancient Greek headwords.

Verb exports can include source-backed subject evidence: whether a documented passive sense takes a person or a thing, or uses an impersonal construction. This is optional lexical information; unmarked senses remain unknown.

Tag and parse sentences

Install the ONNX tagger runtime and download its weights:

python3 -m pip install "dilemma-nlp[tagger-onnx]"
python3 -m dilemma download
from dilemma import Tagger

tagger = Tagger(lang="grc")
for token in tagger.tag(["μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος"])[0]:
    print(token)

The tagger returns token dictionaries with lemmas, part-of-speech tags, morphological features, and dependency relations. Its language options are el, grc, and med. Training requires the separate tagger extra; inference uses tagger-onnx. See the tagger guide for tokenization, model sources, and device settings.

Documentation

Guide Contents
API Methods, conventions, spelling, paradigms, verb subjects, and attestation
Language coverage Periods, dialects, and language codes
Tagging and parsing Sentence annotation, models, and performance
How it works Lookup order, rules, normalization, and model architecture
Evaluation Benchmark methods, recorded results, and limitations
Data Sources, merge rules, present-tense completion, confidence tiers, and validation
Development Setup, training, tests, data publication, and releases
Lexicon expansion LSJ/Sophocles paradigms and form selection
Word lists Frequency inputs, ranked forms, Hunspell dictionaries, and morphology exports
Polytonic Modern Greek Modern word-list construction and validation
Next-word prediction Training, evaluation, and binary export
Monotonic Modern Greek corpus Pinned source archives, normalization, tokenization, and split for monotonic text
Monotonic Modern Greek word list Admission, ratings, preferred spellings, abbreviations, acronyms, and held-out coverage
Monotonic Modern Greek next-word model Counting, pruning, vocabulary size, and held-out evaluation of the monotonic model
Monotonic keyboard data Accent restoration, uppercase dialytika, proposal filtering, enclitics, and keystroke savings

Benchmark results depend on the text, citation convention, available context, and artifact version. Recognition of a spelling and selection of the correct lemma are different measures. The evaluation guide keeps those measures and older comparison results separate.

Development and contributions

git clone https://github.com/open-greek/dilemma.git
cd dilemma
python3 -m pip install -e ".[dev,onnx,lm]"
./scripts/install_git_hooks.sh

The development guide covers data downloads, rebuild order, model training, testing, and numbered GitHub/PyPI releases. Generated artifacts are stored on HuggingFace; data/hf_manifest.json records the hashes of the data and model files that belong to a commit, for CI and for python -m dilemma download.

Report defects and propose changes in GitHub issues. For data errors, include the input word, expected lemma, language and convention settings, and the source supporting the correction. The changelog records changes by release.

Projects and credits

  • Lemma uses Dilemma's frequency-ranked forms in a Modern Greek dictionary.
  • Tonos uses its Hunspell dictionaries and next-word language model in a polytonic Greek keyboard.

Dilemma draws on Wiktionary, LSJ, Sophocles, GLAUx, Diorisis, AGDT, and other lexica and corpora. The third-party notices list the sources, contributors, licenses, and exclusions. Gorman's treebanks are reserved for evaluation and excluded from shipped artifacts.

License

The source code is MIT licensed. Data and model artifacts remain subject to their source licenses; see NOTICE. © 2026 Open Greek.

Metadata

Release files for dilemma-nlp 1.3.27

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dilemma-nlp 1.3.27
File Size Uploaded Provenance Actions
dilemma_nlp-1.3.27.tar.gz 795.1 kB With provenance Details for dilemma_nlp-1.3.27.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dilemma-nlp 1.3.27
File Interpreter ABI Platform Actions
dilemma_nlp-1.3.27-py3-none-any.whl Python 3 none any Details for dilemma_nlp-1.3.27-py3-none-any.whl

Total release size: 1.0 MB

Release files / dilemma_nlp-1.3.27.tar.gz

Download URL dilemma_nlp-1.3.27.tar.gz
Size 795.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7e8456063d44e1de97f8490edbdd44ddeba11b59c15b32d0ac23dafb137df8b9
BLAKE2b-256 checksum
How to use checksums
2d3bbbed5833c6b3fa62d3a478015f072e2594941c83344d26370c02a0de718b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / dilemma_nlp-1.3.27-py3-none-any.whl

Download URL dilemma_nlp-1.3.27-py3-none-any.whl
Size 230.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9fa20b5794456bb2bf0a0718b8b38ee74ab91e4a3a40b6162988d642f10e1c58
BLAKE2b-256 checksum
How to use checksums
eee824927b615cef892c322f7fbdcfed332399adb7c27add87060d56adb91a74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for dilemma-nlp 1.3.27

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dilemma_nlp-1.3.27.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.3.27 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page