Skip to content

Commit

Permalink
Merge pull request #52 from thevilx/refactorModules
Browse files Browse the repository at this point in the history
refactor persian_chars & remove_ordinal_suffix modules
  • Loading branch information
ali77gh authored Feb 3, 2024
2 parents eff89a7 + fb64de8 commit b699be7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
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

0 comments on commit b699be7

Please sign in to comment.