use super::VowelClassifier;
#[derive(Debug, Clone, Copy, Default)]
pub struct TeluguClassifier;
impl TeluguClassifier {
pub fn new() -> Self {
Self
}
}
static TELUGU_VOWELS: &[char] = &[
'అ', 'ఆ', 'ఇ', 'ఈ', 'ఉ', 'ఊ', 'ఋ', 'ౠ', 'ఌ', 'ౡ', 'ఎ', 'ఏ', 'ఐ', 'ఒ', 'ఓ', 'ఔ', 'ా', 'ి', 'ీ', 'ు', 'ూ', 'ృ', 'ౄ', 'ె', 'ే', 'ై', 'ొ', 'ో', 'ౌ', ];
impl VowelClassifier for TeluguClassifier {
fn is_vowel(&self, c: char) -> bool {
let code = c as u32;
match code {
0x0C05..=0x0C14 => true,
0x0C3E..=0x0C4C => true,
0x0C60..=0x0C63 => true,
_ => false,
}
}
fn script_name(&self) -> &'static str {
"Telugu"
}
fn vowels(&self) -> &[char] {
TELUGU_VOWELS
}
fn is_consonant(&self, c: char) -> bool {
let code = c as u32;
match code {
0x0C15..=0x0C39 => true,
0x0C58..=0x0C5A => true,
0x0C4D => false,
0x0C00..=0x0C04 => false,
_ => false,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_independent_vowels() {
let c = TeluguClassifier::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('ఓ')); assert!(c.is_vowel('ఔ')); }
#[test]
fn test_dependent_vowels() {
let c = TeluguClassifier::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('ై')); }
#[test]
fn test_consonants() {
let c = TeluguClassifier::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 = TeluguClassifier::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('హ')); assert!(c.is_consonant('ళ')); }
#[test]
fn test_virama_not_vowel() {
let c = TeluguClassifier::new();
assert!(!c.is_vowel('్')); assert!(!c.is_consonant('్')); }
#[test]
fn test_diacritics() {
let c = TeluguClassifier::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('ః'));
}
}