diff --git a/crates/proof/src/indic.rs b/crates/proof/src/indic.rs index ad6a52cc80..35a8116fd7 100644 --- a/crates/proof/src/indic.rs +++ b/crates/proof/src/indic.rs @@ -217,6 +217,8 @@ pub fn points(script: Script, word: &[char]) -> Vec { // Malayalam's samvruthokaram, the U sign and a virama (`ക്കു്`), is a vowel: the virama after // it kills nothing and joins nothing. let vowel_virama = |v: usize| script == Script::Malayalam && v > 0 && word[v] == '\u{0D4D}' && word[v - 1] == '\u{0D41}'; + // Malayalam's vertical-bar and circular viramas only kill the vowel: they join no conjunct. + let killer = |v: usize| script == Script::Malayalam && matches!(word.get(v), Some('\u{0D3B}' | '\u{0D3C}')); let live = |i: usize| { // A dot reph leads the cluster it joins. let mut j = if at(i) == Some(Kind::Reph) { i + 1 } else { i }; @@ -235,6 +237,9 @@ pub fn points(script: Script, word: &[char]) -> Vec { if at(j) != Some(Kind::Virama) || vowel_virama(j) { return true; } + if killer(j) { + return false; + } j += 1; while at(j) == Some(Kind::Joiner) { j += 1; @@ -247,7 +252,13 @@ pub fn points(script: Script, word: &[char]) -> Vec { let starts = |i: usize| match script { Script::Tamil => at(i - 1) != Some(Kind::Joiner) && tamil_starts(word, &kinds, i), _ if legacy(i) => false, - _ => ((i >= 3 && legacy(i - 3)) || vowel_virama(i - 1) || !matches!(at(i - 1), Some(Kind::Virama | Kind::Joiner | Kind::Reph))) && live(i), + _ => { + ((i >= 3 && legacy(i - 3)) + || vowel_virama(i - 1) + || killer(i - 1) + || !matches!(at(i - 1), Some(Kind::Virama | Kind::Joiner | Kind::Reph))) + && live(i) + } }; (1..word.len()).filter(|&i| matches!(at(i), Some(Kind::Vowel | Kind::Consonant | Kind::Reph)) && starts(i)).collect() } @@ -432,6 +443,8 @@ mod tests { assert_eq!(ml("അവൾക്കു്"), "അ-വൾ-ക്കു്", "samvruthokaram is a vowel"); assert_eq!(ml("അതു്മാത്രം"), "അ-തു്-മാ-ത്രം", "and joins no conjunct"); assert_eq!(ml("കു\u{200D}മ"), "കു\u{200D}മ", "a joiner after the U sign still binds"); + assert_eq!(ml("അക\u{0D3B}മാ"), "അക\u{0D3B}-മാ", "the vertical-bar virama only kills the vowel"); + assert_eq!(ml("അക\u{0D3C}മാ"), "അക\u{0D3C}-മാ", "so does the circular virama"); assert_eq!(ml("അവ\u{0D7B}\u{0D4D}\u{0D31}\u{0D46}"), "അ-വ-\u{0D7B}\u{0D4D}\u{0D31}\u{0D46}", "a chillu leading a conjunct"); }