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.

PyPI Downloads

Persian README

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("اون گفت فردا می‌ره کتابخونه و یه کتاب خوب می‌خونه.")

print(doc.tokens)
# ['آن', 'گفت', 'فردا', 'می‌رود', 'کتابخانه', 'و', 'یک', 'کتاب', 'خوب', 'می‌خواند', '.']
print(doc.lemmas)
# ['آن', 'گفت', 'فردا', 'رفت', 'کتابخانه', 'و', 'یک', 'کتاب', 'خوب', 'خواند', '.']
print(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.
  • Jalali date parsing, formatting and Gregorian conversion.
  • Static fastText/word2vec embeddings with sentence pooling.
  • Optional POS, NER, learned ezafe and dependency-parsing 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.

Jalali dates

from rishe import JalaliDate, parse_date

date = parse_date("۱۲ مرداد ۱۴۰۲")        # JalaliDate(1402, 5, 12)
date.iso                                   # '2023-08-03'
date.to_gregorian()                        # (2023, 8, 3)
date.format_persian()                      # '۱۲ مرداد ۱۴۰۲'

JalaliDate.from_gregorian(2023, 8, 3)      # JalaliDate(1402, 5, 12)

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, ezafe and dependency parsing are separate, checksum-verified downloads. They run inside the package without ONNX Runtime or a Python ML stack. The depparse pack is depparse-compact and carries its own CC BY-SA 4.0 notice.

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

pipe = Pipeline(
    pos_pack=hub.path_pack("pos-compact"),
    ner_pack=hub.path_pack("ner-compact"),
    ezafe_pack=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)

parser = Pipeline(depparse_pack=hub.path_pack("depparse-compact"))
for item in parser.depparse("کتاب‌های خوب را به دوستانم می‌دهم."):
    print(item.text, item.head, item.relation)

pipe.pos_batch(["کتاب‌های خوب", "خوب است"])
pipe.ner_batch(["فیروزآبادی گفت.", "عربستان جای خوبی است."])
pipe.ezafe_batch(["کتابخانه مرکزی", "دانشگاه شریف"])

TaggedToken has text, tag, start and end; Entity has text, label, start and end; Dependency has text, head, relation, start and end. Start/end are character offsets; head is zero-based or None for the root. The lower-level ModelPack class is still available when you want one task:

from rishe import ModelPack, hub

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

Embeddings

rishe hub pull rishe-embed-fa-300   # 135 MB, checksum-verified
from rishe import Embeddings, hub

emb = Embeddings(hub.path("rishe-embed-fa-300"))
emb.dim, len(emb)                      # 300, 38864
emb.vector("کتاب")                     # list[float] or None
emb.similarity("کتاب", "خوب")           # cosine similarity
emb.sentence_vector("این کتاب خوب است") # mean of in-vocab token vectors
emb.sentence_similarity("این کتاب خوب است", "کتاب خوبی بود")
emb.most_similar("کتاب", 5)            # [(word, cosine), ...]

rishe-embed-fa-300 is the first-party 30k-article model (38,864 words). hazm-fasttext-300 remains available through hub.pull as a larger external comparison model. The vectors are CC BY-SA 4.0; see NOTICE.md.

CLI

rishe normalize "مي كنم"
rishe tokenize "سلام دنیا" --json
rishe pos "کتاب‌های خوب را به دوستانم می‌دهم."
rishe ner --json "سرلشگر فیروزآبادی به پادشاه عربستان گفت."
rishe ezafe "کتابخانه مرکزی دانشگاه شریف"
rishe depparse --pack path/to/depparse "کتاب‌های خوب را به دوستانم می‌دهم."
rishe similar کتاب --top 5
rishe similarity کتاب خوب
rishe hub info pos-compact
rishe hub verify pos-compact
rishe hub remove pos-compact

Docs

License

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

The code license does not cover downloaded model weights. The rishe-embed-fa-300 vectors are released under CC BY-SA 4.0, and each optional task pack carries its own terms; see NOTICE.md.

Built by Mahdi Alikhah.

Metadata

Release files for rishe 0.9.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.9.0
File Size Uploaded Provenance Actions
rishe-0.9.0.tar.gz 1.9 MB With provenance Details for rishe-0.9.0.tar.gz

Built distributions (wheels)

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

Total release size: 70.6 MB

Release files / rishe-0.9.0.tar.gz

Download URL rishe-0.9.0.tar.gz
Size 1.9 MB
Tags Source
SHA-256 checksum
How to use checksums
dacaa89882a28bb147e7c157f80d7f9fe1f8fcfee79c918a87fde60a021cf6b6
BLAKE2b-256 checksum
How to use checksums
82f4ddc593e5006118000f533ed90fd565278d4d99431142c92875b383f1add6
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 5, 2026.

Transparency log

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

Download URL rishe-0.9.0-cp39-abi3-win_amd64.whl
Size 10.7 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
8eff5d2184f063f0db1287ea07f3af30d99ee37223b229adc4271d8b0bab60a3
BLAKE2b-256 checksum
How to use checksums
9702378288afd80f32f0d15c6eaf948ebf4ed28b12d2dd95e4da863e334a87e9
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 5, 2026.

Transparency log

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

Download URL rishe-0.9.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 12.9 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
baf5c985ab042f46caa001c08febeb18429ff01fc847c92996d747350c701fd4
BLAKE2b-256 checksum
How to use checksums
15053bfc18da47af9901f8aa82addf32687648be45d69223fe3148743dc200c1
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 5, 2026.

Transparency log

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

Download URL rishe-0.9.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
a0cb8a134ea955e1a7324b3b6d448ed4ff4e54867d96035204c08784987b8322
BLAKE2b-256 checksum
How to use checksums
d932f658d67d24f5b8e80e0ecc24000ff659269602d2d2d98e724bf5cbb176a4
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 5, 2026.

Transparency log

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

Download URL rishe-0.9.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 11.9 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
dafc1452ad7e158c51fe718735d02afe74192e3be58ba096d13432d9cb030b25
BLAKE2b-256 checksum
How to use checksums
0198e6629cd95ae7f85efd3cd22ebb2469478e58d9a2cb9805c4b844d85f3dda
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 5, 2026.

Transparency log

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

Download URL rishe-0.9.0-cp39-abi3-macosx_11_0_arm64.whl
Size 10.3 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a72e79ba4985914851014b1cb4590ea2caf6003a71e27b39c4cfad38e5bc341a
BLAKE2b-256 checksum
How to use checksums
6f3c9844b0e8d46d6ae6122fc2cfdea7050b068645adcaf90c6b94441e600aad
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 5, 2026.

Transparency log

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

Download URL rishe-0.9.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 11.1 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1fc52a030093684ccd4893074530ad3154967d45c0b325d41754c5c008667975
BLAKE2b-256 checksum
How to use checksums
8a651819d6003448b94d7594a1da96d77c6e862dea457388763eac8f083939b4
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 5, 2026.

Transparency log

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

Select from 7 files

Attestation for rishe-0.9.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 5, 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.9.0 This release

7 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