proof: Malayalam's vertical-bar and circular viramas join no conjunct

This commit is contained in:
ruchirguitar committed 2026-11-29 20:22:55 +05:30
1 parent de89cc0e30
commit a482a59510
1 file changed
+14 -1
+14 -1
View File
@@ -217,6 +217,8 @@ pub fn points(script: Script, word: &[char]) -> Vec<usize> {
// 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<usize> {
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<usize> {
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");
}