readsight 1.0.1

Multilingual readability library — 86 languages, 17 formulas, TeX-based syllable counting via the Frank M. Liang algorithm.
Documentation
//! TeX-based syllable counter (delegates to the hyphenator).

use std::rc::Rc;

use crate::hyphenation::{Hyphenator, LiangHyphenator};

use super::counter::SyllableCounter;

/// A syllable counter that delegates directly to a [`LiangHyphenator`].
pub struct TexSyllableCounter {
    hyphenator: Rc<LiangHyphenator>,
}

impl TexSyllableCounter {
    /// Wrap a shared hyphenator.
    pub fn new(hyphenator: Rc<LiangHyphenator>) -> Self {
        TexSyllableCounter { hyphenator }
    }
}

impl SyllableCounter for TexSyllableCounter {
    fn count_syllables(&self, word: &str) -> i64 {
        self.hyphenator.count_syllables(word)
    }

    fn split_syllables(&self, word: &str) -> Vec<String> {
        self.hyphenator.hyphenate(word)
    }
}