lexf 0.1.0

Zero-unsafe multilingual morphological expander and query normalizer for search indexing
Documentation
//! Greek inflection suffix stemmer.

use super::{has_char_n, strip_keep};

/// Minimum chars a word needs before stemming.
const MIN_WORD: usize = 5;
/// Minimum chars a Greek stem must keep.
const MIN_STEM: usize = 3;
/// Common inflection suffixes (final sigma already folded to `σ`), longest first.
const SUFFIX: &[&str] = &[
  "ουμε", "ετε", "ουν", "εισ", "οσ", "εσ", "ασ", "ησ", "ει", "ων", "ου", "α", "ο", "ε", "η", "ω",
  "σ",
];

/// Emits the stem of an already accent-folded Greek word.
pub(crate) fn emit(fold: &str, out: &mut impl FnMut(&str)) {
  if has_char_n(fold, MIN_WORD)
    && let Some(stem) = strip_keep(fold, SUFFIX, MIN_STEM)
  {
    out(stem);
  }
}