Skip to main content

turkmorph

Lossless Turkish morphological tokenizer with a Rust runtime and a Python API. Words are split into roots and suffixes. Suffixes are stored as archiphonemic ids, so -ler/-lar are both S:PL and -den/-dan/-ten/-tan are all S:ABL. Decoding regenerates the exact surface text: decode(encode(text)) == text holds for any input.

License. The code is Apache-2.0. The runtime tables shipped inside the wheel (turkmorph/data/) are CC BY-SA 4.0, because they are derived from CC BY-SA resources (UD Turkish treebanks, BellaTurca). If you redistribute the tables, or modified versions of them, the attribution and share-alike terms apply. No non-commercial resource is used. See NOTICE in the source distribution for the full list of sources.

Install

pip install turkmorph

Wheels are built for Linux (x86_64, aarch64), macOS (Intel, Apple Silicon) and Windows (x64), for Python ≥ 3.10. Other platforms build from source, which needs a Rust toolchain.

Usage

from turkmorph.fast import fast_tokenizer

tok = fast_tokenizer()
tok.encode("Öğretmenlerimizden NATO'ya gidemeyeceklermiş.")
# ['<cap>', 'R:öğretmen#N', 'S:PL', 'S:P1PL', 'S:ABL', '<capsb>', 'R:nato#PROPER', '<apos>',
#  'S:DAT', 'R:git#V', 'S:IMPOT', 'S:FUT', 'S:Z3PL', 'S:ECOP', 'P:.']

ids = tok.encode_ids(text)              # integer ids for a model (vocabulary: 58,667)
assert tok.decode_ids(ids) == text      # lossless
tok.encode_batch(texts, threads=6)      # multi-threaded, releases the GIL

decode_ids accepts any id sequence, which makes it safe to use on model samples. A pure-Python implementation that produces the same tokens is available as turkmorph.presets.full_tokenizer().

Vocabulary

namespace count content
R: 39,653 roots, with part of speech (R:ev#N, R:git#V)
L: 16,143 BPE pieces for words without a known root
E: 2,304 spelling edits
S: 240 suffixes; 39 of them are union ids for ambiguous chains (S:P3SG|ACC)
B: / P: / D: 256 / 43 / 10 bytes, punctuation, digits
specials 18 casing (<cap>, <caps>), apostrophe, whitespace, …

Changes in 0.3.0

  • Canonical roots. One id per lemma where the surface does not decide: koyun and koyunlar now use R:koyun#N, and the homograph variant R:koyun#N.1 appears only where it is needed (koynu). Tagged root tokens drop by about 80% on running text.
  • -CAsInA after person endings. yapmışsınızcasına and gelmişlercesine now analyse fully.
  • Longer chains. The maximum suffix chain grew from 10 to 12, so Çekoslovakyalılaştıramadıklarımızdanmışsınızcasına now analyses fully.
  • Same vocabulary. The 58,667 tokens are unchanged, so models trained with 0.2.x still load. Some words tokenize differently; for exact reproduction of those models, pin turkmorph==0.2.*.

Known limitations

  • Ambiguity. Ambiguous analyses are resolved without context (Gelecek hafta → gel+FUT).
  • Unknown roots. Words without a known root fall back to BPE pieces. When no suffix chain fits, a word is split into BPE pieces as a whole: a known prefix is not kept.
  • Foreign words. Foreign words can get spurious Turkish analyses (fine → fi+P2SG+DAT).
  • Acronyms. Foreign acronyms get Turkish lowercasing (COVID → covıd). Fixing this needs a new case mark, which is planned for a vocabulary-changing release.

Models and experiments

  • turkmorph-gpt-360m: a Turkish GPT trained on turkmorph tokens. It needs the turkmorph 0.2.x vocabulary.
  • Language-model comparisons with BPE, evaluation scripts and design notes are in the repository.

Metadata

Release files for turkmorph 0.3.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 turkmorph 0.3.0
File Size Uploaded Provenance Actions
turkmorph-0.3.0.tar.gz 6.8 MB With provenance Details for turkmorph-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for turkmorph 0.3.0
File Actions
turkmorph-0.3.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for turkmorph-0.3.0-cp310-abi3-win_amd64.whl
turkmorph-0.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for turkmorph-0.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
turkmorph-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for turkmorph-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
turkmorph-0.3.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for turkmorph-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
turkmorph-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for turkmorph-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 43.1 MB

Release files / turkmorph-0.3.0.tar.gz

Download URL turkmorph-0.3.0.tar.gz
Size 6.8 MB
Tags Source
SHA-256 checksum
How to use checksums
99bbeb53b26f2c9a14035dda1d7428e19cd818b8188003c32512a3d0a316672f
BLAKE2b-256 checksum
How to use checksums
96bc4a4e665a6de198cc39ce19edae819500f81f5f9c5037909e2e8ebec8bab9
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 25, 2026.

Transparency log

Release files / turkmorph-0.3.0-cp310-abi3-win_amd64.whl

Download URL turkmorph-0.3.0-cp310-abi3-win_amd64.whl
Size 7.3 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
fe8cc719450191861555c4f2b1c884331d12ebd844ab7ae78b3caf15ce84caf5
BLAKE2b-256 checksum
How to use checksums
0c9a8c14f028f2026e7e50bbb5f08d414ce929dec0105db5487c201f2c5a2b71
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 25, 2026.

Transparency log

Release files / turkmorph-0.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL turkmorph-0.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 7.3 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
ebb4246fd04c6f1c54ceef95d786068d44e1ae906561dd04f435ed82a7c862ce
BLAKE2b-256 checksum
How to use checksums
5294d0c1f0e8ec228027e4f1d4367e8aeba92a5a6e04fb80a81c7785ae514357
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 25, 2026.

Transparency log

Release files / turkmorph-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL turkmorph-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 7.3 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
6c9b6092ec9fead5ea73ce55120cabeedf87941d325448ad2eb5b240042b79c6
BLAKE2b-256 checksum
How to use checksums
3789785610be76996701272b18f0e74c1f7b4cb8a802a1c3f94b94d45869e81c
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 25, 2026.

Transparency log

Release files / turkmorph-0.3.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL turkmorph-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
Size 7.2 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
403f30c525eea40cd31b2154da5c263361cc40b0cd5488b8fd10f0a356f3e4d1
BLAKE2b-256 checksum
How to use checksums
2a91d0cadebd387b20fdef1b4a2cb49ad1bb854247d0fa412dc043fb93ade26f
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 25, 2026.

Transparency log

Release files / turkmorph-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL turkmorph-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 7.3 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
a9ebc7f1f723ac7dc3a670107eceabd0f88dd04340c603c1583933438f48f2c8
BLAKE2b-256 checksum
How to use checksums
608d8da1c95d33b127b652ff886a571e43ed516dc0b9fbaee7a29e59ff0ecb1d
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 25, 2026.

Transparency log

Security for turkmorph 0.3.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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for turkmorph-0.3.0.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 25, 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

0.3.0 This release

6 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