Skip to content

Fix Serbian noun synthesis rules for all 4 declension classes (Vrsta I-IV)#198

Open
nciric wants to merge 3 commits into
unicode-org:mainfrom
nciric:serbian-cpp-synthesis-rules
Open

Fix Serbian noun synthesis rules for all 4 declension classes (Vrsta I-IV)#198
nciric wants to merge 3 commits into
unicode-org:mainfrom
nciric:serbian-cpp-synthesis-rules

Conversation

@nciric

@nciric nciric commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements complete C++ rule-based noun inflection synthesis for Serbian (sr) covering all four primary declension classes (Vrste I – IV) in standard Serbian grammar:

  1. Class I (I Vrsta — Genitive Sg ): Masculine consonant nouns (ученик, прозор, уранак) and unexpanded neuter / nouns (село, поље, уточиште).
  2. Class II (II Vrsta — Genitive Sg with stem extension): Neuter nouns expanding stem with -н- (име -> имена, време -> времена) or -т- (дете -> детету, дугме -> дугмета, пиле -> пилета).
  3. Class III (III Vrsta — Genitive Sg ): Nouns ending in (жена, кућица, Никола, пратња, двојка).
  4. Class IV (IV Vrsta — Genitive Sg ): Feminine consonant nouns ($i$-declension) including primary Instrumental Singular iotation (љубављу, памећу, младошћу, кошћу, ноћу).

Key Refactorings & Optimizations

  • Zero-Allocation Case Index Lookup: Replaced runtime std::map heap allocation per call in applySuffix with a constexpr size_t getCaseIndex(std::u16string_view targetCase) helper function (addressing George's feedback in PR Implementing group 3 noun rules for Serbian. #173).
  • Disambiguation of -ште Neuters: Excluded Class I -ште neuters (уточиште, положиште) from Class II -ет- stem extension.

Note on Suffix Guessing PR #197

ℹ️ Note: PR #197 (Auto-generated Serbian exemplar suffix mapping table) will be reverted/closed once this C++ synthesis PR lands, as rule-based synthesis now natively covers all four Serbian noun declension classes.

Testing

  • Verified with make check -j8 against ICU 78 (263 test cases, 290,506 assertions passed 100%).

nciric added 3 commits July 21, 2026 01:25
…I-IV)

Implement complete C++ rule-based noun inflection synthesis for Serbian in SrGrammarSynthesizer_SrDisplayFunction:
- Vrsta I: Masculine consonant nouns and unexpanded neuter -o/-e nouns.
- Vrsta II: Neuter -e nouns with -n- and -t- stem extensions (ime -> imena, dete -> detetu, pile -> pileta).
- Vrsta III: Nouns ending in -a (zena, Nikola, kucica).
- Vrsta IV: Feminine consonant nouns (i-declension) with instrumental singular iotation (ljubavlju, pamecu, mladoscu, koscu, nocu).
- Optimize case index lookup using constexpr getCaseIndex (addressing PR 173 feedback).
- Add comprehensive structured test suite coverage for all 4 declension classes in sr.xml.
Split inflectByRuleConsonant into inflectByRuleFeminineConsonant (Class IV)
and inflectByRuleMasculineConsonant (Class I) for cleaner modularity and
readability. Clean up line indentation.
Apply clang-format with WebKit style, 120 column limit, and
NamespaceIndentation: None across SrGrammarSynthesizer_SrDisplayFunction.cpp.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant