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

Wheels for CPython 3.9 – 3.14: Linux (glibc and musl), macOS (Intel and Apple Silicon) and Windows x86_64. On 3.8 or older pip stops with No matching distribution found; there is no wheel for it. Free-threaded CPython (3.13t, 3.14t) and PyPy are not supported. Building from a source release needs Rust 1.91.

Quickstart

import rishe

rishe.normalize("مي كنم")                     # 'می‌کنم'
rishe.tokenize("سلام دنیا")                    # ['سلام', 'دنیا']
rishe.lemmatize("می‌روم")                      # 'رفت'

text = "اون گفت فردا می‌ره کتابخونه و یه کتاب خوب می‌خونه."
rishe.process(text).tokens                     # normalized tokens, see below
rishe.process(text).formal_text                # 'آن گفت فردا می‌رود کتابخانه و یک کتاب خوب می‌خواند.'

normalize, tokenize and lemmatize are single steps: no object needed. process runs the whole pipeline in one call — normalization, colloquial → formal rewriting, tokenization, lemmatization, sentence splitting and ezafe — and returns a result object with all of those fields. Bind it once when you need more than one field from the same run:

doc = rishe.process(text)
doc.tokens        # ['آن', 'گفت', 'فردا', 'می‌رود', 'کتابخانه', 'و', 'یک', 'کتاب', 'خوب', 'می‌خواند', '.']
doc.lemmas        # ['آن', 'گفت', 'فردا', 'رفت', 'کتابخانه', 'و', 'یک', 'کتاب', 'خوب', 'خواند', '.']
doc.formal_text   # 'آن گفت فردا می‌رود کتابخانه و یک کتاب خوب می‌خواند.'

Other single steps are module-level calls as well: rishe.sent_tokenize, rishe.tokenize_spans, rishe.mask, rishe.keywords, rishe.stem. All of them share one default pipeline, created on first use. Pipeline(...) remains for configuration (model packs, normalizer flags) and for the methods that have no module-level function, such as conjugate, rake, textrank and spell_correct.

Class-based API

The drop-in class API lives in rishe.compat (the same classes are exported from the package root):

from rishe.compat 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.
  • Drop-in class API (rishe.compat): Normalizer, WordTokenizer, SentenceTokenizer, Lemmatizer, Stemmer and TokenSplitter.
  • Optional POS, NER, learned ezafe and dependency-parsing model packs.

Feature tour

Morphology and utilities

import rishe
pipe = rishe.pipeline()   # the shared default; Pipeline(...) for packs and flags
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(text, stages=[...]) applies individual operators in the order you list them; mask(text, maskers=[...]) removes or masks URLs, emails, mentions, hashtags, HTML, digits, diacritics, punctuation, stopwords, offensive words and non-Persian text.

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

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

Utilities, keywords and transliteration

pipe.number_to_words(1404)                 # 'یک هزار و چهارصد و چهار'
pipe.ngrams("این یک متن", 1, 2)             # ['این', 'یک', 'متن', 'این یک', 'یک متن']
pipe.persianize("فایل را با کامپیوتر باز کن")  # 'پرونده را با رایانه باز کن'
pipe.rake(text, n=5)
pipe.textrank(text, 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.tokenize("رفته است", join_verb_parts=True)   # ['رفته_است']
pipe.tokenize("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

The readers parse CoNLL-U, PEYMA and one-sentence-per-line text. The sample corpora live in the GitHub repository, not in the wheel or the sdist, so point the path at your own file:

from rishe import ConlluReader, PeymaReader, PlainTextReader

for sentence in ConlluReader("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. The test corpora used in this repo's own suite are under data/corpora/ in the repository (gitignored, so a clone does not fetch them); see scripts/pull_test_packs.py.

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("pos-compact"),
    ner_pack=hub.path("ner-compact"),
    ezafe_pack=hub.path("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("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("pos-compact"))
pack.tags("کتاب‌های خوب")   # typed TaggedToken list
pack.tags_from_words(["کتاب‌های", "خوب"])  # tuple output

Embeddings

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

emb = Embeddings(hub.path("rishe-embed-fa-300-v2"))
emb.dim, len(emb), emb.dtype           # 300, 68144, 'f16'
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-v2 is the first-party model: 300 dimensions, 68,144 words, trained on 150,000 Wikipedia articles. The hub serves the compact binary .rvec file, which stores IEEE 754 binary16 values and decodes them back to f32 on load; the same matrix is also published as word2vec text, and Embeddings accepts either file. The 0.9.x 30,000-article pack remains available as rishe-embed-fa-300, and hazm-fasttext-300 is still downloadable as a larger external comparison model. The vectors are CC BY-SA 4.0; see NOTICE.md.

CLI

The pos, ner, ezafe, depparse, similar and similarity commands need a model: pull the packs first (see Model packs), or pass --model / --pack with a path. The rest work on a fresh install.

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-v2 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 1.0.8

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 1.0.8
File Size Uploaded Provenance Actions
rishe-1.0.8.tar.gz 1.5 MB With provenance Details for rishe-1.0.8.tar.gz

Built distributions (wheels)

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

Total release size: 71.9 MB

Release files / rishe-1.0.8.tar.gz

Download URL rishe-1.0.8.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
9971075287e66beb942847e3f4408f36be08e02c1705cddeb5f3f31954cbe5ad
BLAKE2b-256 checksum
How to use checksums
70813c74168ca8e880b8e69297c9a9764a46cf14542075bc88f2f39d3df39794
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 22, 2026.

Transparency log

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

Download URL rishe-1.0.8-cp39-abi3-win_amd64.whl
Size 10.1 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ad3f726f471dec247527e6c2b52da69172a9bdd902ee161df07ffa4087f4dfd6
BLAKE2b-256 checksum
How to use checksums
9d679c9791fb676ee612e3b4ed88f238e44addef29073e35f336a417d7146f8a
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 22, 2026.

Transparency log

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

Download URL rishe-1.0.8-cp39-abi3-musllinux_1_2_x86_64.whl
Size 10.2 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
193839732e06dff903d9728b1115eb10546c5eea2b0f35440f275c512b2a166d
BLAKE2b-256 checksum
How to use checksums
e069f46e1c3bac66925842aadeb59b0bcce3ad0a0fd1c2f8e4379e43c84ab038
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 22, 2026.

Transparency log

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

Download URL rishe-1.0.8-cp39-abi3-musllinux_1_2_aarch64.whl
Size 9.2 MB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
c617997c053741a2299f78a5bcb1b1a584b28d7c67ae7aa169704f49371f031a
BLAKE2b-256 checksum
How to use checksums
726d9d1527efc8324ff30191693d021f10310bb14ab1136792498e4ade5cc67d
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 22, 2026.

Transparency log

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

Download URL rishe-1.0.8-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 11.4 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
c69a41f14c046c8cf301706c13470c96e7f5c6f815211cf4162fa799db443a03
BLAKE2b-256 checksum
How to use checksums
447330ac6c23c64d8d8b9c40c220ce6453afc033b116071b3870bf531003cef8
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 22, 2026.

Transparency log

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

Download URL rishe-1.0.8-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 9.2 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
62cb4f4bcea9b2fc49463a0aa9f979423fd64e5f6b0eedf43df51fb4595a7cb6
BLAKE2b-256 checksum
How to use checksums
cb54ad3cff21b9a3d4c2a207f0426cc14ea7afea65ef246206551d08781b7b2c
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 22, 2026.

Transparency log

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

Download URL rishe-1.0.8-cp39-abi3-macosx_11_0_arm64.whl
Size 9.8 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
35d99fd5af45e69544b774912a9e5a8d02b987fb9ad6eddc4a974fe97cbed661
BLAKE2b-256 checksum
How to use checksums
17e1214807c45a0046e92806ec3dc33159206af6231d7c334b49a2a16a972ccd
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 22, 2026.

Transparency log

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

Download URL rishe-1.0.8-cp39-abi3-macosx_10_12_x86_64.whl
Size 10.6 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
cea86276746b4d77ed298a1a47013d1e930e3e7bb749b905d980d92f5e091fde
BLAKE2b-256 checksum
How to use checksums
b63833d8f6f89b82feef6920149e1f8cf91df27bba7104071d022807adc3bde9
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 22, 2026.

Transparency log

Security for rishe 1.0.8

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-1.0.8.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 22, 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

1.0.8 This release

8 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