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.

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 = 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.

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 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; the repository manifest records the hashes used by CI.

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.16

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.16
File Size Uploaded Provenance Actions
dilemma_nlp-1.3.16.tar.gz 573.8 kB With provenance Details for dilemma_nlp-1.3.16.tar.gz

Built distribution (wheel)

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

Total release size: 749.5 kB

Release files / dilemma_nlp-1.3.16.tar.gz

Download URL dilemma_nlp-1.3.16.tar.gz
Size 573.8 kB
Tags Source
SHA-256 checksum
How to use checksums
aeebd68593a3003b3766c7880d3068cb02587826d2dcce1091fffe6518e42a92
BLAKE2b-256 checksum
How to use checksums
8a12e3197060cb874e683cc4bf9a630455043a1f585fb54c25f4c2c5cae1e79e
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 9, 2026.

Transparency log

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

Download URL dilemma_nlp-1.3.16-py3-none-any.whl
Size 175.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f76481a99617f47809900082584df9e70e230590984522fc2759612ec025435
BLAKE2b-256 checksum
How to use checksums
4d275f7e5cc6680775498600cac653187f691f7314b0612eee91c1e1320b92da
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 9, 2026.

Transparency log

Security for dilemma-nlp 1.3.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.

Full provenance

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

Select from 2 files

Attestation for dilemma_nlp-1.3.16.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 9, 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.16 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