Implement German compound word tokenizer and fix head word capitalization#196
Implement German compound word tokenizer and fix head word capitalization#196nciric wants to merge 3 commits into
Conversation
…word capitalization
Technical Investigation: Case Sensitivity in
|
This is a bad assumption. It does not return null in this scenario. I remain skeptical on the letter casing of this pull request. |
Correction + deeper investigation on dictionary lookup casing@george you're right, and my earlier comment was wrong on the mechanism: The lookup succeeds, but resolves to the wrong entry.
Net: Could we instead fix
|
| Locale | Input | Expected | Got |
|---|---|---|---|
| de | decken {accusative, singular} |
decke |
decken |
| en | Jones {genitive} |
Jones's |
Jones' |
Folding a capitalized word's grammemes onto its lowercase homonym pollutes the POS/number/gender bits that downstream inflection rules rely on — which is exactly what the existing comment warns against ("Don't override previous value because this isn't an exact value").
And even ignoring the regressions, it's the wrong layer: the inflection lookup is separate and case-sensitive. DictionaryLookupInflector resolves patterns via getInflectionPatternsForWord(word) keyed by the exact string, retrying only with a lowercased variant (never capitalized), and InflectionDictionary does no case-folding. So frau can only ever resolve to paradigm 13b; the noun paradigm 1 lives exclusively under Frau. Merging grammemes would hand frau the noun bits but still leave it inflecting with the pronoun paradigm.
Conclusion: capitalizing the compound head word to Frau in DeGrammarSynthesizer is the correct, targeted layer — it fixes the lookup key for both the grammeme metadata and the inflection paradigm, scoped to German compounds rather than globally reshaping the dictionary data model. Not a null-lookup problem (my mistake), but a lowercase-homonym-shadowing problem.
We can discuss this more in the meeting.
This PR implements the German compound word tokenizer (
DeTokenizer) and integrates it into the inflection engine. It also resolves capitalization lookup issues for lowercased head-word segments resulting from compound splitting.Key Changes
1. German Tokenizer Infrastructure & Configuration (
DeTokenizer)DeTokenizerandDeDictionaryTokenizerConfigregistered inTokenizerFactory.cpp./de/tokenizer.tokd) inconfig_de.properties.s,es,e,n,en,er,ens) inDeDictionaryTokenizerConfig.2. German Head-Word Capitalization Lookup
fraufromEhefrau) are checked against capitalized noun entries (Frau) indictionary.getCombinedBinaryTypeto resolvenounPOS andfemininegender morphology, restoring lower-case formatting oninflectedHeadWordafter inflection synthesis.3. German Tokenizer Dictionary
tokenizer.dictionaryfor German containing word frequencies and flags (isNoCompound,isNoAtomic,isSegment).Verification
TokenizerTest.cppcovering German compound splitting (Hauptstraße,Waldweg,Schlossgasse,Marktplatz,Kaiserring,Sonnenallee,Arbeitszimmer,Kindergarten).make check- all 264 test cases passed (290,502 assertions).