pub struct Chandas { /* private fields */ }
Expand description
A metrical classifier.
§Usage
use vidyut_chandas::{Chandas, MatchType, Vrtta};
let vrttas: Vec<Vrtta> = vec![
"vasantatilakA\tvrtta\tGGLGLLLGLLGLGG".try_into().unwrap(),
"mandAkrAntA\tvrtta\tGGGGLLLLLGGLGGLGG".try_into().unwrap(),
"puzpitAgrA\tvrtta\tLLLLLLGLGLGG/LLLLGLLGLGLGG".try_into().unwrap(),
"udgatA\tvrtta\tLLGLGLLLGL/LLLLLGLGLG/GLLLLLLGLLG/LLGLGLLLGLGLG".try_into().unwrap()
];
let chandas = Chandas::new(vrttas);
let result = chandas.classify("mAtaH samastajagatAM maDukEwaBAreH");
assert_eq!(result.vrtta().as_ref().unwrap().name(), "vasantatilakA");
assert_eq!(result.match_type(), MatchType::Pada);
Implementations§
Source§impl Chandas
impl Chandas
Sourcepub fn from_text(data: &str) -> Result<Self, Box<dyn Error>>
pub fn from_text(data: &str) -> Result<Self, Box<dyn Error>>
Creates a new Chandas
instance by defining meters from the given text data.
We recommend using this constructor when the program does not have access to the filesystem, e.g. when using this code in WebAssembly.
Sourcepub fn from_file(path: &Path) -> Result<Self, Box<dyn Error>>
pub fn from_file(path: &Path) -> Result<Self, Box<dyn Error>>
Creates a new classifier from the given data path.
Sourcepub fn classify(&self, text: impl AsRef<str>) -> MatchResult
pub fn classify(&self, text: impl AsRef<str>) -> MatchResult
Classifies the input string against an internal list of meters.
Currently, this function supports only simple samavrtta.
Trait Implementations§
impl Eq for Chandas
impl StructuralPartialEq for Chandas
Auto Trait Implementations§
impl Freeze for Chandas
impl RefUnwindSafe for Chandas
impl Send for Chandas
impl Sync for Chandas
impl Unpin for Chandas
impl UnwindSafe for Chandas
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more