Datasets:
Download code/INSTALL.md from Chapimenge/amharic-gemination-lexicon: direct link, hf CLI and curl.
- Browser
- Download file 3.34 kB
-
https://huggingface.co/datasets/Chapimenge/amharic-gemination-lexicon/resolve/main/code/INSTALL.md
- Command line
-
hf download hf://datasets/Chapimenge/amharic-gemination-lexicon/code/INSTALL.md
-
curl -L -o INSTALL.md https://huggingface.co/datasets/Chapimenge/amharic-gemination-lexicon/resolve/main/code/INSTALL.md
Running the extractor
gemination.py has no dependencies of its own. To turn new words into
gemination patterns it needs HornMorpho 5.3.6 (Michael Gasser,
https://github.com/hltdi/HornMorpho) with two small patches.
One command
./install_hornmorpho.sh .venv-hm # Python 3.9 or newer; set PYTHON=... to choose one
LANG=C.UTF-8 .venv-hm/bin/python gemination.py ይገኛል ክልል መለወጥ
LANG=C.UTF-8 .venv-hm/bin/python test_gemination.py
Expected output of the second line (tab-separated):
ይገኛል ይገ፟ኛ፟ል positions=[1, 2] sources=['t-prefix', 'root'] pos=V root_freq=3688 seg=----ይ</ገ/ኝ>---ኣ/ል---
ክልል ክል፟ል positions=[1] sources=['lexicon'] pos=N root_freq=1 seg=-<ክ/ልል>------
መለወጥ መለ፟ወጥ positions=[1] sources=['t-prefix'] pos=N root_freq=84 seg=-<መ/-ለወጥ>------
መለወጥ መለወ፟ጥ positions=[2] sources=['root'] pos=N root_freq=84 seg=-<መ-ለ/ወጥ>------
መለወጥ has two readings (passive mälläwäṭ, active mäläwwäṭ), so it prints two patterns. Only sentence context can choose between them.
What the script does, step by step
- Install the wheel. HornMorpho is not on PyPI. The script downloads
dist/hornmorpho-5.3.6-py3-none-any.whlfrom the HornMorpho repository at commit7e3d93af760e27ea6dbc3b7a078d2d9c3335f618and checks its sha256 (e1b0e4ed...fa7). Dependenciesconlluandrequestscome with it. - Patch 1, Tk GUI stub (
patches/gui.py, replaceshm/morpho/gui.py).hm/morpho/corpus.pydoesfrom .gui import *at import time, soimport hmfails on any Python without_tkinter. The stub defines the one namecorpus.pyrefers to. Applied only whenimport tkinterfails. - Patch 2, lexicon loader (
patches/morphology.patch, applied withpatch -p1inside site-packages).words1.srflines areortho phon POSwith#comment lines, but the loader built a dict from the raw split, which raises on the first real entry. - Amharic data.
src/hm/languages/a.tgzfrom the same commit (sha2563274f71d...95c), unpacked intohm/languages/.
Always run with a UTF-8 locale (LANG=C.UTF-8).
The call that matters
import hm
readings = list(hm.anal("a", "ይገኛል", degem=False)) # degem=False keeps the '/' marks
With the default degem=True the / marks are stripped from seg, and the
only gemination information left is the +gemN root feature, which misses
every geminate created by a prefix or a suffix. That was the bug in v1 of this
lexicon.
import gemination as G
G.analyze("ይገኛል") # runs HornMorpho, returns patterns, most frequent root first
G.word_gemination(word, readings) # same, from readings you already have
G.reading_gemination(word, {"seg": "----ይ</ገ/ኝ>---ኣ/ል---"}) # one seg, no HornMorpho needed
G.mark("ይገኛል", [1, 2]) # 'ይገ፟ኛ፟ል'
Rebuilding the release files
build_lexicon.py converts the internal lexicon (one entry per word with the
stored HornMorpho segs) into data/. It re-derives every pattern from its segs
and stops if any disagrees, so the data cannot drift from this extractor.