"""
sindhinltk.stemmer — Morphological stemmer for Sindhi.

Advanced rule-based suffix stripping for Sindhi verb/noun forms.

NOTE: This is a STUB for the v1.1 package structure.
      Copy your existing stemmer code from v1.0.4 into this file.
      The public API must expose: stem(word) -> str
"""

# ┌─────────────────────────────────────────────────────────┐
# │  PASTE YOUR EXISTING stemmer.py CODE FROM v1.0.4 HERE  │
# │  Keep the same stem() function signature.              │
# └─────────────────────────────────────────────────────────┘

# Common Sindhi suffixes used for stemming (reference list)
_SUFFIXES = [
    # Verbal (longest first)
    'ائيندڙ', 'يائين', 'ائيندو', 'ائيندي',
    'يندڙ', 'يندو', 'يندي', 'ائين', 'ائيو',
    'ندڙ', 'ندو', 'ندي',
    # Nominal
    'ون', 'ين', 'ان', 'ڙا', 'ڙي', 'ڙو',
]


def stem(word: str) -> str:
    """
    Stem a Sindhi word by stripping known suffixes.

    Args:
        word: A Sindhi word string.

    Returns:
        The stemmed form (root/stem).

    Example:
        >>> from sindhinltk.stemmer import stem
        >>> stem('ڪتابون')
        'ڪتاب'
    """
    if len(word) < 4:
        return word

    for suffix in _SUFFIXES:
        if word.endswith(suffix) and len(word) > len(suffix) + 2:
            return word[:-len(suffix)]

    return word
