rustam
A full Persian NLP pipeline for Rust — normalization, tokenization, stemming, lemmatization, conjugation, informal-to-formal conversion, spell correction, and more.
Features
- Normalization — character translation, diacritics removal, spacing fixes, Unicode ligature replacement
- Informal normalization — colloquial-to-formal Persian conversion with multi-candidate output
- Sentence tokenization — boundary detection using Persian and Latin punctuation patterns
- Word tokenization — whitespace/punctuation splitting with optional multi-part verb joining
- Stemming — rule-based suffix stripping (longest-match, lexicon-aware)
- Lemmatization — dictionary lookup + full conjugation table fallback
- Conjugation — generates every tense/mood/voice form for a Persian verb root pair
- Token splitting — compound token decomposition using the word lexicon
- Spell correction — frequency-ranked correction from the embedded lexicon
- Corpus readers — Bijankhan, Arman, Peykare, Hamshahri, NAAB, and more
- Embedding traits —
WordEmbedding/SentenceEmbeddinginterfaces for pluggable backends
Quick start
[]
= "0.1"
use ;
let text = "اِعلاممممم کَرد : « زمین لرزه ای به بُزرگیِ 6 دهم ریشتر ...»";
let norm = new;
let normalized = norm.normalize;
// → "اعلام کرد: «زمینلرزهای به بزرگی ۶ دهم ریشتر …»"
let stemmer = new;
assert_eq!;
let lem = new;
assert_eq!;
Informal normalization
use InformalNormalizer;
let n = new;
let candidates = n.normalized_word;
// → ["برای", "واسه"] (informal → formal candidates)
Conjugation
use Conjugation;
let c = Conjugation;
let forms = c.perfective_past;
// → ["دیدم", "دیدی", "دید", "دیدیم", "دیدید", "دیدند"]
Optional features
| Feature | Enables |
|---|---|
pos |
POS tagger and chunker (crftag) |
ner |
Named entity recognizer (nerrs) |
dep-parsing |
Arc-eager dependency parser (arc-eager) |
hf-hub |
Model download from Hugging Face Hub |
full |
All of the above |
Pre-trained models
The hf-hub feature downloads pre-trained Persian NLP models (POS tagger, chunker, NER, dependency parser, word embeddings) from Hugging Face Hub. Pre-trained weights are provided by the roshan-research organization and are used here with gratitude.
License
MIT