feat: Add vowel harmony validator for suffix stripping (#52)#53
Open
ada-cinar wants to merge 2 commits into
Open
feat: Add vowel harmony validator for suffix stripping (#52)#53ada-cinar wants to merge 2 commits into
ada-cinar wants to merge 2 commits into
Conversation
## Changes ### Rust Core (src/lib.rs) - ✅ Add vowel harmony validation functions: - is_back_vowel() / is_front_vowel() - get_last_vowel() / get_first_vowel() - check_vowel_harmony() - validates backness harmony - check_vowel_harmony_py() - Python API wrapper - ✅ Update strip_suffixes() to respect vowel harmony: - Prevents false positives (e.g., 'kitapler' with a-e mismatch) - Maintains min stem length constraint (>= 2 chars) - Recursive stripping validates harmony at each step ### Tests - ✅ 14 Rust unit tests (all passing): - Vowel detection (back/front) - Vowel extraction (first/last) - Harmony validation (valid/invalid cases) - Suffix stripping with harmony constraints - Edge cases (no vowels, short stems, recursion) - ✅ 7 Python integration tests (added): - check_vowel_harmony_py() API tests - Lemmatizer harmony validation - Recursive stripping with harmony ## Linguistic Background Turkish suffixes follow strict vowel harmony: - **Backness harmony**: Suffix vowel must match stem's last vowel - Back vowels: a, ı, o, u - Front vowels: e, i, ö, ü Examples: - ✅ kitap + lar → Valid (a-a harmony) - ✅ ev + ler → Valid (e-e harmony) - ❌ kitap + ler → Invalid (a-e mismatch) - ❌ ev + lar → Invalid (e-a mismatch) ## Impact - Improves morphological analysis accuracy - Prevents over-stripping in heuristic lemmatizer - Foundation for future morphological analyzer - Exposes harmony checker to Python API for research use Closes #52
- Update README.md with vowel harmony feature examples - Add check_vowel_harmony_py to Python type stubs (_durak_core.pyi) - Document vowel harmony constraint in strip_suffixes docstring - Add usage examples for harmony validation Closes #52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements vowel harmony validation to prevent false positives in suffix stripping. Turkish suffixes must respect backness harmony (back vowels: a/ı/o/u, front vowels: e/i/ö/ü).
Changes
Core Implementation
strip_suffixes()to validate harmony before strippingcheck_vowel_harmony_py(stem, suffix)Tests
Examples
Before (naive stripping):
After (harmony-aware):
Impact
Closes #52