Conversation
inflection/src/inflection/grammar/synthesis/SrGrammarSynthesizer_SrDisplayFunction.cpp
Outdated
Show resolved
Hide resolved
| static constexpr auto suffix_sg = ::std::to_array<::std::u16string_view>({u"а", u"е", u"и", u"у", u"а", u"ом", u"и"}); | ||
| static constexpr auto suffix_pl = ::std::to_array<::std::u16string_view>({u"е", u"а", u"ама", u"е", u"е", u"ама", u"ама"}); | ||
|
|
||
| ::std::u16string base = lemma; | ||
| // Remove trailing a and apply suffix. | ||
| base.pop_back(); | ||
| base = applySuffix(base, suffix_sg, suffix_pl, number, targetCase); |
There was a problem hiding this comment.
For this kind of mapping, you may be inspired by Arabic, German or Italian. They convert a string to a numeric key (makeLookupKey) containing multiple grammemes, and they map the key to a string. This mapping is initialized in the constructor instead of at runtime.
There was a problem hiding this comment.
Is the concern the runtime size increase (static constexpr)? If yes, I can remove the static (creating these arrays is cheap).
Otherwise the current approach looks simpler. I will look into refactoring this code as I add more cases, potentially implementing Arabic like approach.
WDYT?
There was a problem hiding this comment.
It was to make it more scalable, but this is fine too.
inflection/src/inflection/grammar/synthesis/SrGrammarSynthesizer_SrDisplayFunction.cpp
Outdated
Show resolved
Hide resolved
inflection/src/inflection/grammar/synthesis/SrGrammarSynthesizer_SrDisplayFunction.cpp
Outdated
Show resolved
Hide resolved
inflection/src/inflection/grammar/synthesis/SrGrammarSynthesizer_SrDisplayFunction.cpp
Show resolved
Hide resolved
inflection/src/inflection/grammar/synthesis/SrGrammarSynthesizer_SrDisplayFunction.cpp
Outdated
Show resolved
Hide resolved
inflection/src/inflection/grammar/synthesis/SrGrammarSynthesizer_SrDisplayFunction.cpp
Outdated
Show resolved
Hide resolved
inflection/src/inflection/grammar/synthesis/SrGrammarSynthesizer_SrDisplayFunction.cpp
Outdated
Show resolved
Hide resolved
grhoten
left a comment
There was a problem hiding this comment.
Changes look fine. Optional comments to consider where also provided.
inflection/src/inflection/grammar/synthesis/SrGrammarSynthesizer_SrDisplayFunction.cpp
Outdated
Show resolved
Hide resolved
| <test><source case="genitive" number="plural" gender="feminine" pos="noun">конзерва</source><result>конзерви</result></test> | ||
| <test><source case="genitive" number="plural" gender="feminine" pos="noun">гошћа</source><result>гошћа</result></test> | ||
| <test><source case="genitive" number="plural" gender="feminine" pos="noun">двојка</source><result>двојака</result></test> | ||
| <test><source case="genitive" number="plural" gender="feminine" pos="noun">битка</source><result>битака</result></test> |
There was a problem hiding this comment.
You have a lot of fully fleshed out constraints. Most of the other languages only change specific grammemes. Sometimes you only specify the case, number or gender. The other tests usually specify less. The other languages usually default to noun. These tests are currently fine, but common usage starts from any surface form (ideally a unique surface form), and then you modify just the relevant grammemes.
There was a problem hiding this comment.
I can probably remove noun info, but I do need a case, gender and number for rule based approach to work.
I also assume nominative input (lemma) - otherwise the rules would be more complex, or would need dictionary support to implement them.
| static constexpr auto suffix_sg = ::std::to_array<::std::u16string_view>({u"а", u"е", u"и", u"у", u"а", u"ом", u"и"}); | ||
| static constexpr auto suffix_pl = ::std::to_array<::std::u16string_view>({u"е", u"а", u"ама", u"е", u"е", u"ама", u"ама"}); | ||
|
|
||
| ::std::u16string base = lemma; | ||
| // Remove trailing a and apply suffix. | ||
| base.pop_back(); | ||
| base = applySuffix(base, suffix_sg, suffix_pl, number, targetCase); |
There was a problem hiding this comment.
It was to make it more scalable, but this is fine too.
Fully implements group 3 (all nouns ending with -a).
This removes a need for a large number of nouns to be added to Wikidata.
Resolves part of #172 .