Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor persian_chars & remove_ordinal_suffix modules #52

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/persian_chars/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
use std::borrow::Cow;

pub mod chars {
pub static FA_ALPHABET: &str = "ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی";
pub static FA_NUMBER: &str = "۰۱۲۳۴۵۶۷۸۹";
pub static FA_SHORT_VOWELS: &str = "َُِ";
pub static FA_OTHERS: &str = "‌آاً";
pub static FA_MIXED_WITH_ARABIC: &str = "ًٌٍَُِّْٰٔءك‌ةۀأإيـئؤ،";
pub static FA_TEXT: &str = "ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی۰۱۲۳۴۵۶۷۸۹َُِ‌آاً؟ ";
pub static FA_COMPLEX_TEXT: &str = "ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی۰۱۲۳۴۵۶۷۸۹َُِ‌آأًًٌٍَُِّْٰءك‌ةۀأإيـئؤ،؟ ";
}
Expand Down
14 changes: 5 additions & 9 deletions src/remove_ordinal_suffix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,17 @@ where

if word.ends_with("مین") {
word = word[0..word.len() - ("مین".len())].to_string()
}
if word.ends_with("اُم") {
} else if word.ends_with("اُم") {
word = word[0..word.len() - ("اُم".len())].trim().to_string()
}
if word.ends_with("ام") {
} else if word.ends_with("ام") {
word = word[0..word.len() - ("ام".len())].trim().to_string()
}

if word.ends_with("سوم") {
} else if word.ends_with("سوم") {
word = word[0..word.len() - ("سوم".len())].to_string();
word += "سه";
}
if word.ends_with('م') {
} else if word.ends_with('م') {
word = word[0..word.len() - ("م".len())].to_string()
}

word
}

Expand Down