Skip to main content

Rishe: fast Persian text processing for Python, built in Rust

Rishe (ریشه)

Fast Persian text processing for Python, built in Rust.

Rishe (root in Persian) turns raw Persian text into clean, structured data in a single call: normalized text, tokens, lemmas, sentences, ezafe markers, and a formal rewrite of colloquial writing. The core is Rust; you get it as a pip install with prebuilt wheels, no models to download, and no runtime dependencies.

from rishe import Pipeline

pipe = Pipeline()
doc = pipe("اون داره تو خونه کتاب میخونه، چیه؟")

doc.tokens       # ['آن', 'دارد', 'تو', 'خانه', 'کتاب', 'می‌خواند', '،', 'چیست', '؟']
doc.lemmas       # ['آن', 'داشت', 'تو', 'خانه', 'کتاب', 'خواند', '،', 'چیست', '؟']
doc.formal_text  # 'آن دارد تو خانه کتاب می‌خواند، چیست؟'

Why Rishe

  • Normalization about 80× faster than Hazm and Shekar: 1.2 µs per sentence against 98 µs and 105 µs.
  • Millions of tokens per second. 1.0M tokens/s on one thread; pipe() runs batches in parallel with the GIL released and reaches 6.5M tokens/s on 12 threads.
  • Everything in one call. Normalization, informal → formal conversion, tokenization, lemmatization, sentence splitting and ezafe detection from one Pipeline object, in about 17 µs per sentence.
  • Accurate where it counts. Tokenization F1 of 1.000 on UD-Seraji and 0.999 on UD-PerDT, ahead of Shekar (0.999 and 0.998) and Hazm (0.981 and 0.961), and ahead of both on PEYMA. Lemma accuracy of 0.92 on UD-Seraji and 0.93 on UD-PerDT, ahead of Hazm (0.90 and 0.90) and Shekar (0.81 and 0.82).
  • Informal Persian handled. Colloquial forms (اون, خونه, داره, میخوام, چیه) are rewritten to their formal spelling as part of the pipeline, and fused clitics like بهش are split into به + او.
  • Nothing to set up. Compiled-in lexicons (190k nouns, 1.2k verb stems), no model downloads, no Python dependencies, no network access.
  • Wheels for every major platform. Linux (glibc and musl, x86_64 and aarch64), macOS (Intel and Apple Silicon) and Windows, for Python 3.9+ (abi3). The same core is available as a Rust crate.
  • Thread-safe. One Pipeline can be shared across threads.

Benchmarks

Measured against Hazm and Shekar on the full UD Persian-Seraji, UD Persian-PerDT and PEYMA test sets, with every library built once and reused.

Speed (per sentence, single thread)

Rishe Hazm Shekar
Normalize 1.2 µs 97 µs 104 µs
Tokenize 4.1 µs 5.9 µs 4.4 µs

Accuracy

Task Dataset Rishe Compared with
Token F1 UD-Seraji 1.0000 Shekar 0.9992, Hazm 0.9810
Token F1 UD-PerDT 0.9989 Shekar 0.9976, Hazm 0.9609
Token F1 PEYMA 0.9028 Shekar 0.9018, Hazm 0.8901
Lemma accuracy UD-Seraji 0.9209 Hazm 0.9048, Shekar 0.8068
Lemma accuracy UD-PerDT 0.9316 Hazm 0.9009, Shekar 0.8179

The full tables, the batch-throughput scaling across thread counts, and the method are in docs/BENCHMARKS.md. Reproduce everything with python scripts/benchmark.py.

Install

pip install rishe        # Python >= 3.9

or, from Rust (Cargo.toml): rishe = "0.1"

Usage

from rishe import Pipeline

pipe = Pipeline()                         # unify digits, strip diacritics, fix ZWNJ

doc = pipe("کتاب‌های خوب را به دوستانم می‌دهم.")
doc.normalized_text, doc.formal_text, doc.sentences
doc.tokens, doc.lemmas, doc.ezafe_markers

docs = pipe.pipe(texts)                   # parallel batch -> list[ProcessedDoc]

pipe.normalize("مي كنم 2026")             # 'می‌کنم ۲۰۲۶'
pipe.tokenize("سلام، دنیا!")              # raw tokenization, no normalization
pipe.word_tokenize("سلام، دنیا!")         # normalize + tokenize
pipe.sent_tokenize(text)                  # sentence splitting only
pipe.lemmatize("می‌روم")                   # 'رفت'  (past-stem lemmas, UD style)

pipe(text) also rewrites colloquial words to formal ones, so its tokens can differ from the surface text; word_tokenize tokenizes without rewriting. tokenize is the fast raw path used for the tokenization benchmarks.

use rishe::Pipeline;

let pipe = Pipeline::create(true, true, true); // unify digits, strip diacritics, fix ZWNJ
let doc = pipe.process("کتاب‌های خوب را به دوستانم می‌دهم.");
println!("{:?}", doc.tokens);

Scope

Rishe is a text-preprocessing engine: normalization, tokenization, sentence splitting, lemmatization, ezafe detection and informal → formal conversion. For POS tagging, NER or parsing, use it as the fast preprocessing step in front of a tagger.

Building from source

cargo test
maturin develop --release     # Python extension into the current venv
python scripts/benchmark.py   # needs: hazm shekar conllu

scripts/extract_lexicons.py regenerates data/*.tsv from Hazm's data files; build.rs compiles them into FSTs.

License

Dual-licensed under Apache-2.0 or MIT, at your option. The bundled lexicons are derived from Hazm data (MIT); see NOTICE.md.

Metadata

Release files for rishe 0.1.1

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

Source distribution (sdist)

Source distribution for rishe 0.1.1
File Size Uploaded Provenance
rishe-0.1.1.tar.gz 1.1 MB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for rishe 0.1.1
File
rishe-0.1.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
rishe-0.1.1-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details
rishe-0.1.1-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details
rishe-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
rishe-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
rishe-0.1.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
rishe-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 9.5 MB

Release files / rishe-0.1.1.tar.gz

Download URL rishe-0.1.1.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
ca091c525f884a25601edcd3a3414c4941dbe079ed84310f231264e80d63bb47
BLAKE2b-256 checksum
How to use checksums
244e0681a94c76e5de4becbe229e9a68db5a949cfd1b3380aabd8452f50e30f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 20, 2026.

Transparency log

Release files / rishe-0.1.1-cp39-abi3-win_amd64.whl

Download URL rishe-0.1.1-cp39-abi3-win_amd64.whl
Size 1.0 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1176427f67b1f1dda7451ceb7459d0e397dcae016e684bf561d6025f6cfd74a1
BLAKE2b-256 checksum
How to use checksums
455e0fbd46504eaca4b6a15aa3006520c814cafe038d3f19e98cb08198490687
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 20, 2026.

Transparency log

Release files / rishe-0.1.1-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL rishe-0.1.1-cp39-abi3-musllinux_1_2_x86_64.whl
Size 1.4 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
cec718bb82fa79c40f09cf5117e780e270955acbdf45cc25c84702230bebef08
BLAKE2b-256 checksum
How to use checksums
fb1c101183884412d6fd60e9b3277fce4f9ecc026ac2425449a884a8d3a818cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 20, 2026.

Transparency log

Release files / rishe-0.1.1-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL rishe-0.1.1-cp39-abi3-musllinux_1_2_aarch64.whl
Size 1.4 MB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
d01a2d12c02602cb540b1c51a53291510baf0bc70167420e8c48d51a3053727a
BLAKE2b-256 checksum
How to use checksums
4ebbc2ba3bfdb1f7bf1c1722ace12e11698371bee582f69cd33d28f7e6735838
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 20, 2026.

Transparency log

Release files / rishe-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rishe-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.2 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
ea65091d37197e83db1f7234553da46b16a812c5a6f9953de0370f251e51bb12
BLAKE2b-256 checksum
How to use checksums
c54687892357cb956cd75a701c504e09cf0b3ee3f37b2a105a5f396df28a755a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 20, 2026.

Transparency log

Release files / rishe-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL rishe-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.2 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
305e3e31f8411f3a2035a6ab234fc540f47d3ddcbde01ff1dcf5f701ccd03431
BLAKE2b-256 checksum
How to use checksums
01252378039dc9a4620fd1704afb2c209fea492d17265b89960205fc66ea5902
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 20, 2026.

Transparency log

Release files / rishe-0.1.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL rishe-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d5077605ef1ba2355fba0e6e7ed945ebfc1e04b0c38ae41570f62b4b4150418e
BLAKE2b-256 checksum
How to use checksums
2a9c377b2fd739c2bc99aabe0794efa053ccfc8ca74e53b0cab94552ee1ddee5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 20, 2026.

Transparency log

Release files / rishe-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl

Download URL rishe-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl
Size 1.2 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
f2f25b76e5740883653a6ff28f62413adfa177ae0d9312f8d9fd328e1ad54c2e
BLAKE2b-256 checksum
How to use checksums
0cb4826c64c6d4b2fe0602c7b57af36d6a685abe60c61c45fb02bfe6eaa61631
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 20, 2026.

Transparency log

Security for rishe 0.1.1

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 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for rishe-0.1.1.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 Oct 20, 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.

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