Chapimenge's picture
Amharic gemination lexicon v3
cf15858 verified
|
Raw History Blame Contribute Delete
3.34 kB

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

  1. Install the wheel. HornMorpho is not on PyPI. The script downloads dist/hornmorpho-5.3.6-py3-none-any.whl from the HornMorpho repository at commit 7e3d93af760e27ea6dbc3b7a078d2d9c3335f618 and checks its sha256 (e1b0e4ed...fa7). Dependencies conllu and requests come with it.
  2. Patch 1, Tk GUI stub (patches/gui.py, replaces hm/morpho/gui.py). hm/morpho/corpus.py does from .gui import * at import time, so import hm fails on any Python without _tkinter. The stub defines the one name corpus.py refers to. Applied only when import tkinter fails.
  3. Patch 2, lexicon loader (patches/morphology.patch, applied with patch -p1 inside site-packages). words1.srf lines are ortho phon POS with # comment lines, but the loader built a dict from the raw split, which raises on the first real entry.
  4. Amharic data. src/hm/languages/a.tgz from the same commit (sha256 3274f71d...95c), unpacked into hm/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.