use super::VowelClassifier;
#[derive(Debug, Clone, Copy, Default)]
pub struct GujaratiClassifier;
impl GujaratiClassifier {
pub fn new() -> Self {
Self
}
}
static GUJARATI_VOWELS: &[char] = &[
'અ', 'આ', 'ઇ', 'ઈ', 'ઉ', 'ઊ', 'ઋ', 'એ', 'ઐ', 'ઓ', 'ઔ', 'ા', 'િ', 'ી', 'ુ', 'ૂ', 'ૃ', 'ે', 'ૈ', 'ો', 'ૌ', ];
impl VowelClassifier for GujaratiClassifier {
fn is_vowel(&self, c: char) -> bool {
let code = c as u32;
match code {
0x0A85..=0x0A94 => true,
0x0ABE..=0x0ACC => true,
0x0AE0..=0x0AE3 => true,
_ => false,
}
}
fn script_name(&self) -> &'static str {
"Gujarati"
}
fn vowels(&self) -> &[char] {
GUJARATI_VOWELS
}
fn is_consonant(&self, c: char) -> bool {
let code = c as u32;
match code {
0x0A95..=0x0AB9 => true,
0x0ACD => false,
0x0A81..=0x0A83 => false,
_ => false,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_independent_vowels() {
let c = GujaratiClassifier::new();
assert!(c.is_vowel('અ')); assert!(c.is_vowel('આ')); assert!(c.is_vowel('ઇ')); assert!(c.is_vowel('ઈ')); assert!(c.is_vowel('ઉ')); assert!(c.is_vowel('ઊ')); assert!(c.is_vowel('ઋ')); assert!(c.is_vowel('એ')); assert!(c.is_vowel('ઐ')); assert!(c.is_vowel('ઓ')); assert!(c.is_vowel('ઔ')); }
#[test]
fn test_dependent_vowels() {
let c = GujaratiClassifier::new();
assert!(c.is_vowel('ા')); assert!(c.is_vowel('િ')); assert!(c.is_vowel('ી')); assert!(c.is_vowel('ુ')); assert!(c.is_vowel('ૂ')); assert!(c.is_vowel('ૃ')); assert!(c.is_vowel('ે')); assert!(c.is_vowel('ૈ')); }
#[test]
fn test_consonants() {
let c = GujaratiClassifier::new();
assert!(!c.is_vowel('ક')); assert!(!c.is_vowel('ખ')); assert!(!c.is_vowel('ગ')); assert!(!c.is_vowel('ઘ')); assert!(!c.is_vowel('ચ')); assert!(!c.is_vowel('જ')); assert!(!c.is_vowel('ત')); assert!(!c.is_vowel('દ')); assert!(!c.is_vowel('ન')); assert!(!c.is_vowel('પ')); assert!(!c.is_vowel('મ')); assert!(!c.is_vowel('હ')); }
#[test]
fn test_is_consonant() {
let c = GujaratiClassifier::new();
assert!(c.is_consonant('ક')); assert!(c.is_consonant('ગ')); assert!(c.is_consonant('ત')); assert!(c.is_consonant('ન')); assert!(c.is_consonant('મ')); assert!(c.is_consonant('હ')); }
#[test]
fn test_virama_not_vowel() {
let c = GujaratiClassifier::new();
assert!(!c.is_vowel('્')); assert!(!c.is_consonant('્')); }
#[test]
fn test_diacritics() {
let c = GujaratiClassifier::new();
assert!(!c.is_vowel('ઁ')); assert!(!c.is_vowel('ં')); assert!(!c.is_vowel('ઃ')); assert!(!c.is_consonant('ઁ'));
assert!(!c.is_consonant('ં'));
assert!(!c.is_consonant('ઃ'));
}
}