You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
Implemented DeTokenizer and DeDictionaryTokenizerConfig registered in TokenizerFactory.cpp.
Configured German to use the new tokenizer and compiled binary dictionary (/de/tokenizer.tokd) in config_de.properties.
Configured German Fugenelemente (s, es, e, n, en, er, ens) in DeDictionaryTokenizerConfig.
2. German Head-Word Capitalization Lookup
Lowercased compound head-word segments (e.g. frau from Ehefrau) are checked against capitalized noun entries (Frau) in dictionary.getCombinedBinaryType to resolve noun POS and feminine gender morphology, restoring lower-case formatting on inflectedHeadWord after inflection synthesis.
3. German Tokenizer Dictionary
Added tokenizer.dictionary for German containing word frequencies and flags (isNoCompound, isNoAtomic, isSegment).
Verification
Added unit tests in TokenizerTest.cpp covering German compound splitting (Hauptstraße, Waldweg, Schlossgasse, Marktplatz, Kaiserring, Sonnenallee, Arbeitszimmer, Kindergarten).
Executed make check - all 264 test cases passed (290,502 assertions).
Technical Investigation: Case Sensitivity in DictionaryMetaData Lookup
Following review discussion regarding case sensitivity during dictionary lookup, we investigated how DictionaryMetaData::getCombinedBinaryType and underlying Trie lookups behave in the engine:
1. Trie Byte Matching
Dictionary entries in the binary dictionary (e.g. Frau, Weg, Strasse) are stored in a marisa::Trie (MarisaTrie.hpp), which performs exact byte-sequence lookups.
2. One-Way Lowercasing Fallback in getCombinedBinaryType
In DictionaryMetaData::getCombinedBinaryType (DictionaryMetaData.cpp):
Uppercase/Capitalized inputs (Frau / FRAU): First checks exact match Frau, then falls back to lowercasing frau.
Lower-case inputs (frau): Searches frau (fails, as entry is stored as Frau), then transform lowercases frau -> frau (normalized == word), returning nullptr.
Conclusion for German Compound Tokenization
When a compound noun like Ehefrau is split into Ehe + frau, the head segment frau is lowercased. Because getCombinedBinaryType does not perform capitalization fallback for lowercased inputs, capitalizing frau -> Frau before getCombinedBinaryType is necessary for frau to resolve noun properties (dictionaryNoun | dictionaryFeminine) from capitalized dictionary entries.
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
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.
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).