Expand description
§rustam
Rustam is a full Persian NLP pipeline for Rust: normalization, tokenization, stemming, lemmatization, conjugation, informal normalization, corpus readers, spell correction, and embedding backends.
- Normalization — character translation, diacritics removal, spacing fixes
- Informal normalization — colloquial-to-formal Persian conversion
- Sentence tokenization — boundary detection using punctuation patterns
- Word tokenization — splits words, joins multi-part verbs
- Stemming — rule-based suffix stripping
- Lemmatization — dictionary lookup with full conjugation table
- Conjugation — generates every tense/mood/voice form for a verb
- Token splitting — compound token decomposition using the lexicon
- Corpus readers — Bijankhan, Arman and more
- Embedding traits —
WordEmbedding/SentenceEmbeddinginterface
§Quick-start
use rustam::{Normalizer, SentenceTokenizer, WordTokenizer, Stemmer, Lemmatizer};
let text = "اِعلاممممم کَرد : « زمین لرزه ای به بُزرگیِ 6 دهم ریشتر ...»";
// Normalize
let norm = Normalizer::new();
let normalized = norm.normalize(text);
// Sentence split
let sent_tok = SentenceTokenizer::new();
let sentences = sent_tok.tokenize(&normalized);
// Word tokenize
let word_tok = WordTokenizer::new();
let tokens = word_tok.tokenize(&normalized);
// Stem
let stemmer = Stemmer::new();
assert_eq!(stemmer.stem("کتابها"), "کتاب");
// Lemmatize
let lem = Lemmatizer::new();
assert_eq!(lem.lemmatize("میروم", ""), "رفت#رو");Re-exports§
pub use conjugation::Conjugation;pub use data::past_roots;pub use data::present_roots;pub use data::stopwords_list;pub use data::verbs_list;pub use data::words_list;pub use error::Error;pub use error::Result;pub use informal::InformalLemmatizer;pub use informal::InformalNormalizer;pub use lemmatizer::Lemmatizer;pub use normalizer::Normalizer;pub use normalizer::NormalizerConfig;pub use sentence_tokenizer::sent_tokenize;pub use sentence_tokenizer::SentenceTokenizer;pub use spell::SpellCorrector;pub use stemmer::Stemmer;pub use token_splitter::TokenSplitter;pub use types::ChunkedSentence;pub use types::ChunkedToken;pub use types::IobTag;pub use types::Sentence;pub use types::Tag;pub use types::TaggedSentence;pub use types::TaggedToken;pub use types::Token;pub use types::VerbRoots;pub use types::WordEntry;pub use word_tokenizer::word_tokenize;pub use word_tokenizer::WordTokenizer;pub use word_tokenizer::WordTokenizerConfig;
Modules§
- conjugation
- Persian verb conjugation — generates every tense/mood/voice form.
- constants
- Compile-time constants: suffix lists, punctuation sets.
- data
- Embedded data files (lexicon, verbs, stopwords) compiled into the binary.
- error
- Library-wide error type and
Resultalias. - informal
- Informal (colloquial) Persian normalization and lemmatization. Informal-to-formal Persian normalization.
- lemmatizer
- Dictionary-based lemmatizer with conjugation fallback.
- normalizer
- Multi-step text normalizer (diacritics, spacing, Unicode).
- sentence_
tokenizer - Sentence boundary tokenizer for Persian text.
- spell
- Persian spell corrector based on lexicon frequency. Persian spell corrector.
- stemmer
- Rule-based suffix-stripping stemmer.
- token_
splitter - Compound token splitter using the word lexicon. Splits a compound token into valid sub-word pairs using the lexicon.
- translate
- Arabic–Persian word translation table.
- types
- Core type aliases (
Token,TaggedSentence, etc.). - word_
tokenizer - Word tokenizer with optional verb-part joining.