Repository navigation
Conversation
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.
384dc44 to
6163a80
Compare
6163a80 to
59d47b5
Compare
…coded test function
59d47b5 to
c2d99e0
Compare
| // for dictionary lookup to avoid missing the noun entry or matching a lowercase | ||
| // homonym with a different POS (e.g., matching pronoun 'frau' instead of noun 'Frau'). |
There was a problem hiding this comment.
After some thought, and if this is the main concern, it would be quicker and more accurate to do a POS check from the getCombinedBinaryType result than to modify the casing during lookup.
You can always find the lower cased forms of all words because that is how the dictionary normalizes the words, and the lower cased forms are collapsed with the title cased forms. This is important when a word is camel cased, which can also be encountered.
You can never miss a word by incorrect casing, but you can disambiguate if necessary.
It's also worth pointing out that DeGrammarSynthesizer_DeDisplayFunction won't inflect pronouns, but it will inflect nouns.
This code already works with a German decompounder, but at least 1 test case was modified when contributing this code to avoid the decompounded test case. See the constructor for the parts of speech and priorities on inflecting such words.
From what I can tell, this is unnecessary work. Was the Ehefrau test in resources/inflection/dialog/inflection/de.xml failing with your changes?
| TEST_CASE("TokenizerTest#testGermanDictionary") | ||
| { | ||
| ::std::unique_ptr<::inflection::tokenizer::Tokenizer> tokenizer(::inflection::tokenizer::TokenizerFactory::createTokenizer(::inflection::util::LocaleUtils::GERMANY())); | ||
| compareValueTokens(tokenizer->createTokenChain(u"Hauptstraße"), {u"", u"Haupt", u"straße", u""}); | ||
| compareValueTokens(tokenizer->createTokenChain(u"Waldweg"), {u"", u"Wald", u"weg", u""}); | ||
| compareValueTokens(tokenizer->createTokenChain(u"Schlossgasse"), {u"", u"Schloss", u"gasse", u""}); | ||
| compareValueTokens(tokenizer->createTokenChain(u"Marktplatz"), {u"", u"Markt", u"platz", u""}); | ||
| compareValueTokens(tokenizer->createTokenChain(u"Kaiserring"), {u"", u"Kaiser", u"ring", u""}); | ||
| compareValueTokens(tokenizer->createTokenChain(u"Sonnenallee"), {u"", u"Sonne", u"n", u"allee", u""}); | ||
| compareValueTokens(tokenizer->createTokenChain(u"Arbeitszimmer"), {u"", u"Arbeit", u"s", u"zimmer", u""}); | ||
| compareValueTokens(tokenizer->createTokenChain(u"Kindergarten"), {u"", u"Kinder", u"garten", u""}); | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
These types of tests are best kept in test/resources/inflection/tokenizer/de.xml. It's harder to maintain here in C++. Some of the other tests in this file can probably move to the data driven tests some day.
|
I think that the tokenizer changes are generally fine. I am pushing back on the DeGrammarSynthesizer_DeDisplayFunction.cpp changes because it has worked fine in the past with a different German tokenizer that decompounds. It's an implementation that I can't open source. It's probably a good idea to update the copyrights in these files too. Now if your code were looking up/normalizing variations of ü, ä, and ö, that might be a compelling change to make. This code isn't looking up "ue" nor the NFD forms of ü. All languages pretty much assume NFC. |
|
We can discuss this after top PRs in our meeting. Updated the copyright years to 2026, removed the duplicate In Capitalizing the split compound head is still required for three cases in
|
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).