Skip to main content

kyrgyz-morph-tagger

PyPI License: PolyForm NC

Morphological tagger for Kyrgyz: predicts UPOS, a Kyrgyz-specific XPOS, the lemma, and the full Universal Dependencies feature bundle for every token.

Kyrgyz is agglutinative — one word stacks number, possession, case, voice, negation, tense, mood and person onto a single stem, and a tag is only right if every feature in the bundle is right. This package is a PyTorch re-implementation of the UDPipe 2 architecture, trained on a manually annotated Kyrgyz UD treebank of 8,485 sentences (~98k tokens).

pip install kyrgyz-morph-tagger
from kyrgyz_morph_tagger import Tagger

tagger = Tagger.load()          # downloads the checkpoint once (~48 MB), then caches it

for sentence in tagger.tag("Мектептерибизден эрте келдик."):
    for token in sentence:
        print(token.form, token.lemma, token.upos, token.feats_string)
Мектептерибизден  Мектептер  NOUN   Case=Abl|Number=Plur|Poss=Yes
эрте              эрте       ADV    _
келдик            кел        VERB   Mood=Ind|Number=Plur|Person=1|Polarity=Pos|Tense=Past|Voice=Act
.                 .          PUNCT  _

The first Tagger.load() also pulls xlm-roberta-base (~1.1 GB) through transformers — the tagger reads frozen contextual embeddings from it. Both downloads are cached, so only the first run pays. A GPU is optional: the full 425-sentence test set tags in 12 s on CPU, 2 s on GPU, with identical output.

Usage

Input Call
Raw text (splits sentences, tokenizes) tagger.tag(text)
One raw sentence tagger.tag_sentence(text)
Already-tokenized sentences tagger.tag_pretokenized([["Мектеп", "жакшы", "."]])
A CoNLL-U file (keeps its tokenization and syntax) tagger.tag_conllu("in.conllu", "out.conllu")

The tagger predicts morphology only — HEAD and DEPREL are left untouched.

ky-tag "Мектептерибизден келдик."             # print a table
ky-tag -f text.txt --format conllu            # raw text -> CoNLL-U
ky-tag --conllu in.conllu -o out.conllu       # fill an existing CoNLL-U file
Tagger.load()                        # released model, from the Hugging Face Hub
Tagger.load("path/to/checkpoint")    # a local directory you trained yourself
Tagger.load(revision="v1.0")         # pin a Hub revision for reproducibility
Tagger.load(device="cpu")

Accuracy

Held-out test set (425 sentences), exact match, gold tokenization:

UPOS XPOS UFeats AllTags Lemmas
Released checkpoint (seed 42) 93.90 92.63 81.25 79.44 87.96
Mean ± std over 4 seeds 93.80 ±0.12 92.53 ±0.13 80.96 ±0.33 79.19 ±0.40 88.06 ±0.14

UFeats is exact-set match of the whole feature bundle; AllTags additionally requires UPOS and XPOS to be right. A single wrong feature invalidates the token — which is why UFeats (81) sits far below UPOS (94). That is the honest measure of full morphological analysis, and under the same metric three frontier LLMs given the same tagging scheme in the prompt reach only UFeats 58–60 zero-shot.

Tokenizer. tag() on raw text must tokenize first, which costs a little accuracy on top of the table above. The bundled rule-based tokenizer, scored against the corpus's gold tokenization on the same test set: token F1 99.27, 95.3 % of sentences tokenized exactly right. The sentence splitter recovers ~85 % of boundaries in running text; the ceiling is low for a real reason — 11 % of the corpus's sentences end with no final punctuation at all, and those boundaries cannot be recovered from the surface. If you already have tokens, use tag_pretokenized() and take the tokenizer out of the loop.

The tagset

Universal POS and features stay standard UD; Kyrgyz-specific detail lives in XPOS and in a few declared feature values.

  • Six cases — Nom, Gen, Dat, Acc, Loc, Abl. The instrumental -менен is analysed as a postposition and the similative -дай as derivation, so neither is a case.
  • Deverbal categories — the participle (atooch) and the verbal noun (ktooch) are UPOS=VERB with the appropriate VerbForm, keeping their fine label in XPOS.
  • Ideophones and interjections — UPOS=INTJ, subtype in XPOS.
  • AdjType=Rel|Qual, AdvType=Tim|Loc|Man|Deg, VerbForm=Part|Conv|Vnoun.

17 UPOS tags, 24 XPOS tags, 14 feature categories. The corpus passes the official UD validator (level 2) with zero errors.

Limitations

  • Morphology only; no syntax.
  • Trained on news, web and literary text — other domains will be weaker.
  • Sentences longer than 512 XLM-R subwords lose contextual embeddings for the overflow. The package warns when this happens; split long sentences.

Development

pip install -e ".[dev]"
pytest -m "not model"     # fast: tokenizer and API surface
pytest                    # everything, incl. downloading and running the checkpoint

To run the tokenizer's full gold-corpus regression check, point KY_TREEBANK at a checkout of the treebank.

Licence

PolyForm Noncommercial 1.0.0 — free for research, teaching, personal projects and noncommercial organisations. Commercial use requires a separate licence; contact the licensor.

Be aware of what this means before you depend on it: PolyForm Noncommercial is not an OSI-approved open-source licence, and corporate licence scanners will treat it accordingly. If you need the tagger inside a product, ask — do not assume.

The training corpus is CC BY-SA 4.0 and is distributed separately; it is not shipped in this package, and this licence does not extend to it.

Metadata

Release files for kyrgyz-morph-tagger 1.0.0

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

Source distribution (sdist)

Source distribution for kyrgyz-morph-tagger 1.0.0
File Size Uploaded Provenance Actions
kyrgyz_morph_tagger-1.0.0.tar.gz 27.3 kB Without provenance Details for kyrgyz_morph_tagger-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kyrgyz-morph-tagger 1.0.0
File Interpreter ABI Platform Actions
kyrgyz_morph_tagger-1.0.0-py3-none-any.whl Python 3 none any Details for kyrgyz_morph_tagger-1.0.0-py3-none-any.whl

Total release size: 55.8 kB

Release files / kyrgyz_morph_tagger-1.0.0.tar.gz

Download URL kyrgyz_morph_tagger-1.0.0.tar.gz
Size 27.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1236262a73bdb0eefffe2e057aaaca9320592bfd95cde6c7806d64d0558ccbcf
BLAKE2b-256 checksum
How to use checksums
27dda8e4f04787fb0c136b1bae0bc320c9b65c3ca85f59247f73e8329836fe63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / kyrgyz_morph_tagger-1.0.0-py3-none-any.whl

Download URL kyrgyz_morph_tagger-1.0.0-py3-none-any.whl
Size 28.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b53e8dd7bf3d241a448f5feb5f5fa681a12d13633feec73608b9108f40bc98f
BLAKE2b-256 checksum
How to use checksums
322168f74b3deab7654020673dab1d25f33b5e7aa4eb03d788aae7fd61a914d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for kyrgyz-morph-tagger 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.0.0 This release

2 release files No 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