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 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.
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.17
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dilemma_nlp-1.3.17.tar.gz | 580.6 kB | With provenance | Details for dilemma_nlp-1.3.17.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dilemma_nlp-1.3.17-py3-none-any.whl | Python 3 | none | any | Details for dilemma_nlp-1.3.17-py3-none-any.whl |
Total release size: 759.2 kB
Release files / dilemma_nlp-1.3.17.tar.gz
| Download URL | dilemma_nlp-1.3.17.tar.gz |
|---|---|
| Size | 580.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd5cd20624c73f8aeced46c12efb1716e632acb1ff918cf385c7155dc85e3583
|
|
BLAKE2b-256 checksum How to use checksums |
b0fe4061e1cd40ad43288dec014fdbffcc67ce58f28abd774063426e2023cf4b
|
| 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 logRelease files / dilemma_nlp-1.3.17-py3-none-any.whl
| Download URL | dilemma_nlp-1.3.17-py3-none-any.whl |
|---|---|
| Size | 178.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
30f035c61fee4c5128785c52961e0c9dc99ab7f64de9aae39148bdacf00b4d6f
|
|
BLAKE2b-256 checksum How to use checksums |
cf284f0a09ce25f3d9744448d8e5f5c2acf0322ff2fe282d22c585f8569ddc16
|
| 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 logSecurity for dilemma-nlp 1.3.17
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.
Attestation for dilemma_nlp-1.3.17.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 logA 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.