Skip to main content

Rishe: fast Persian NLP

Rishe (ریشه)

Fast Persian NLP and morphology for Python. Prebuilt wheels, no Python dependencies, and the base pipeline needs no model downloads.

Install

pip install rishe

Python 3.9+. Linux (glibc and musl), macOS and Windows wheels are published.

Quickstart

from rishe import Pipeline

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

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

pipe.normalize, word_tokenize, sent_tokenize, lemmatize, stem, conjugate, spell_correct and the rest are methods on the same object. pipe(text) rewrites colloquial forms; word_tokenize tokenizes the surface text without rewriting.

Class-based API

The same engine is available as small, reusable classes:

from rishe import (
    Lemmatizer,
    Normalizer,
    SentenceTokenizer,
    Stemmer,
    TokenSplitter,
    WordTokenizer,
    sent_tokenize,
    word_tokenize,
)

Normalizer().normalize("مي كنم")             # 'می‌کنم'
WordTokenizer().tokenize("رفته است")         # ['رفته_است']
SentenceTokenizer().tokenize("یک. دو.")
Lemmatizer().lemmatize("می‌روم")              # 'رفت#رو'
Stemmer().stem("کتاب‌ها")                    # 'کتاب'
TokenSplitter().split_token_words("بهش")     # [('به', 'او')]

word_tokenize("رفته است")                    # ['رفته_است']
sent_tokenize("یک. دو.")

No lexicon paths are needed: the classes use Rishe's compiled-in lexicons. WordTokenizer accepts the same options as the pipeline tokenizer (join_verb_parts, replace_emails, replace_links, and so on).

Features

  • Normalization, tokenization, sentence splitting and lemmatization.
  • Stemming, conjugation, inflection, clitic splitting, spell correction, stopwords and ezafe detection.
  • Static fastText/word2vec embeddings with sentence pooling.
  • Optional POS, NER and learned ezafe model packs.

Feature tour

Morphology and utilities

pipe.stem("کتاب‌ها")                      # 'کتاب'
pipe.conjugate("رفت")["present"][:3]      # ['می‌روم', 'می‌روی', 'می‌رود']
pipe.comparative("بزرگ")                  # 'بزرگ‌تر'
pipe.superlative("بزرگ")                  # 'بزرگ‌ترین'
pipe.plural("کتاب")                       # 'کتاب‌ها'
pipe.possessive("خانه", 0)                # 'خانه‌ام'
pipe.split_token("بهش")                   # ['به', 'او']
pipe.spell_correct("سسلام بر ششما")       # 'سلام بر شما'
pipe.tokenize_spans("سلام دنیا")          # [('سلام', 0, 4), ('دنیا', 5, 9)]

Normalization and masking

normalize_stages applies individual operators in the order you list them; mask_stages removes or masks URLs, emails, mentions, hashtags, HTML, digits, diacritics, punctuation, stopwords, offensive words and non-Persian text.

pipe.normalize_stages("﷽ 1𝟮3٤٥⓺", ["arabic_unicode", "digits"])
# 'بسم الله الرحمن الرحیم ۱۲۳۴۵۶'

pipe.mask_stages("سلام @user، به https://rishe.dev یا info@rishe.dev بنویس.",
                 ["url", "email", "mention"])
# 'سلام   به <URL> یا <EMAIL> بنویس.'

Utilities, keywords and transliteration

pipe.number_to_words(1404)                 # 'یک هزار و چهارصد و چهار'
pipe.ngrams("این یک متن", 1, 2)             # ['این', 'یک', 'متن', 'این یک', 'یک متن']
pipe.persianize("فایل را با کامپیوتر باز کن")  # 'پرونده را با رایانه باز کن'
pipe.rake(text, top_n=5)
pipe.textrank(text, top_n=5)
pipe.to_tajik("خانه")                      # 'хона'
pipe.to_persian("хона")                    # 'خانه'

keyboard_noise, ocr_noise and whitespace_noise add reproducible typing, OCR and spacing noise; pass seed= for deterministic output.

Tokenizer options

pipe.word_tokenize_with("رفته است", join_verb_parts=True)   # ['رفته_است']
pipe.word_tokenize_with("info@a.co", replace_emails=True)   # ['EMAIL']

Options include join_verb_parts, join_abbreviations, separate_emoji, replace_links, replace_ids, replace_emails, replace_numbers and replace_hashtags.

Corpora

from rishe import ConlluReader, PeymaReader, PlainTextReader

for sentence in ConlluReader("data/corpora/fa_perdt-ud-test.conllu"):
    print(sentence.text, sentence.tokens[0].lemma)

ConlluReader handles CoNLL-U, PeymaReader reads the PEYMA format and PlainTextReader reads one sentence per line.

Model packs

POS, NER and ezafe are separate, checksum-verified downloads. They run inside the package without ONNX Runtime or a Python ML stack.

rishe hub pull pos-compact
rishe hub pull ner-compact
rishe hub pull ezafe-compact
from rishe import Pipeline, hub

pipe = Pipeline(
    pos_pack=str(hub.path_pack("pos-compact")),
    ner_pack=str(hub.path_pack("ner-compact")),
    ezafe_pack=str(hub.path_pack("ezafe-compact")),
)

for token in pipe.pos("کتاب‌های خوب را به دوستانم می‌دهم."):
    print(token.text, token.tag, token.start, token.end)

for entity in pipe.ner("سرلشگر فیروزآبادی به پادشاه عربستان گفت."):
    print(entity.text, entity.label, entity.start, entity.end)

for token in pipe.ezafe("کتابخانه مرکزی دانشگاه شریف"):
    print(token.text, token.tag, token.start, token.end)

TaggedToken has text, tag, start and end; Entity has text, label, start and end. Start/end are character offsets. The lower-level ModelPack class is still available when you want one task:

from rishe import ModelPack

pack = ModelPack(str(hub.path_pack("pos-compact")))
pack.tag_tokens("کتاب‌های خوب")   # typed TaggedToken list
pack.tag_words(["کتاب‌های", "خوب"])  # tuple output

Embeddings

rishe hub pull hazm-fasttext-300   # optional 2.3 GB static embedding file
from rishe import Embeddings, hub

emb = Embeddings(str(hub.path("hazm-fasttext-300")))
emb.dim, len(emb)                      # vector size, vocabulary size
emb.vector("کتاب")                     # list[float] or None
emb.sentence_vector("این کتاب خوب است") # mean of in-vocab token vectors
emb.most_similar("کتاب", 5)            # [(word, cosine), ...]

CLI

rishe normalize "مي كنم"
rishe tokenize "سلام دنیا" --json
rishe pos "کتاب‌های خوب را به دوستانم می‌دهم."
rishe ner --json "سرلشگر فیروزآبادی به پادشاه عربستان گفت."
rishe ezafe "کتابخانه مرکزی دانشگاه شریف"

Docs

License

Dual-licensed under Apache-2.0 or MIT, at your option. Lexicon attributions are in NOTICE.md.

Built by Mahdi Alikhah.

Metadata

Release files for rishe 0.6.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 rishe 0.6.0
File Size Uploaded Provenance Actions
rishe-0.6.0.tar.gz 1.8 MB With provenance Details for rishe-0.6.0.tar.gz

Built distributions (wheels)

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

Total release size: 81.6 MB

Release files / rishe-0.6.0.tar.gz

Download URL rishe-0.6.0.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
6019f34a7fa807e952d0753c48efe739eab91cc7fa2e030460024365f2cfef72
BLAKE2b-256 checksum
How to use checksums
d6aaefa0a299cab64a3b00a7324ba15051f8533e2e7c9c482906165ad5236397
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 Oct 27, 2026.

Transparency log

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

Download URL rishe-0.6.0-cp39-abi3-win_amd64.whl
Size 10.4 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b1d2cd70db735cea59d89734d0daacbf2e9f7074c05d82b41da0bba6a8c6cdb5
BLAKE2b-256 checksum
How to use checksums
8153e8325ae73955dbfe5aaecba290bb4a0f9e829cfbf42cd59f9177c71c2aad
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 Oct 27, 2026.

Transparency log

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

Download URL rishe-0.6.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 12.8 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
74748ea6325a9890a2c591cdab7e040dace3164b3430c6103b5ca7f28f1289d2
BLAKE2b-256 checksum
How to use checksums
95786b1b4e5d4c97aa649bbe69bb096fca52cb0fde8387f8b8dd71185d1d25a2
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 Oct 27, 2026.

Transparency log

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

Download URL rishe-0.6.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 11.9 MB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
c5909ff24bb8813d505caa5c68cb8c6c25f985e51d7994ece377a51606961a23
BLAKE2b-256 checksum
How to use checksums
84c6df12e256882cddbba151a555dd14ff882db3c351b6b77ec04adee97c72b8
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 Oct 27, 2026.

Transparency log

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

Download URL rishe-0.6.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 11.8 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
860fedc4049280f1ee1e0ac4734988cdde3b763093907ba966e04e46be0ab0e9
BLAKE2b-256 checksum
How to use checksums
7ffcb3c588ec42214b206097892023b945d313688cab2c6cdd86ca0776cce837
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 Oct 27, 2026.

Transparency log

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

Download URL rishe-0.6.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 11.6 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
266ba578957fd376a1921a88e9af181641db5fb2a0f81c0bf7d1b578e1d8d02f
BLAKE2b-256 checksum
How to use checksums
df19ff2ee948b91b85a839aa676cc5b957def1035ce6702a2bc66de4a61ff637
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 Oct 27, 2026.

Transparency log

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

Download URL rishe-0.6.0-cp39-abi3-macosx_11_0_arm64.whl
Size 10.2 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7671d4acb1c9ab7f620a1e3ccb4e448de7105c6f793841b9509b717ce351b3bf
BLAKE2b-256 checksum
How to use checksums
644a738aaddbf6d8bc75bc35e377eab4aaed445cbb1996eb561ac257de9fb893
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 Oct 27, 2026.

Transparency log

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

Download URL rishe-0.6.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 11.0 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
a58964445cda06911ce80e04fe0fd3fab690d589f581a6c55fa73074ccef453e
BLAKE2b-256 checksum
How to use checksums
265844f1906ed660b93ee25d31fd94aa0495a6ca12cf3a75bae94ff6df3f67cf
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 Oct 27, 2026.

Transparency log

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

Select from 8 files

Attestation for rishe-0.6.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 Oct 27, 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