Skip to content

Commit

Permalink
Handle case "robbil alamin" (#32)
Browse files Browse the repository at this point in the history
* add test cases

* handle the case

* bump version
  • Loading branch information
alpancs authored Apr 10, 2023
1 parent e90a113 commit 0a46d17
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quranize"
version = "0.10.5"
version = "0.10.6"
authors = ["Alfan Nur Fauzan <[email protected]>"]
edition = "2021"
description = "Encoding transliterations into Quran forms."
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ mod tests {
assert_eq!(q.e("lirrohman"), vec!["للرحمن"]);
assert_eq!(q.e("wantum muslimun"), vec!["وأنتم مسلمون"]);
assert_eq!(q.e("laa yukallifullah"), vec!["لا يكلف الله"]);
assert_eq!(q.e("robbil alamin"), vec!["رب العالمين"]);

assert_eq!(
q.e("bismillahirrohmanirrohiim"),
Expand Down
16 changes: 10 additions & 6 deletions src/transliterations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,18 @@ pub(crate) fn map(c: char) -> &'static [&'static str] {
}
}

pub(crate) fn contextual_map(prev_c: char, c: char) -> &'static [&'static str] {
match (prev_c, c) {
(' ', 'ا') | ('ب', 'ا') | ('ا', 'ل') | ('آ', 'ل') | ('و', 'ا') | ('أ', 'و') => {
&[""]
}
pub(crate) fn contextual_map(c0: char, c1: char) -> &'static [&'static str] {
match (c0, c1) {
(' ', 'ا')
| ('ب', 'ا')
| ('ا', 'ل')
| ('آ', 'ل')
| ('و', 'ا')
| ('أ', 'و')
| ('ع', 'ا') => &[""],
('\0', 'ا') => &["i", "u"],
('ل', 'ل') => &["i"],
(_, TASYDID) => map(prev_c),
(_, TASYDID) => map(c0),
_ => &[],
}
}
Expand Down

0 comments on commit 0a46d17

Please sign in to comment.