-
-
Notifications
You must be signed in to change notification settings - Fork 17
Inflection 77: Adding C and C++ API for stating source grammemes and tests for the same. #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
c008f15
c8f22ec
70fa3e1
9c8ba42
c41ec8c
e676a21
873db46
52dc3d1
e3851a6
0c4bbeb
fa7133e
2e90004
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,11 +52,40 @@ SpeakableString* InflectableStringConcept::getFeatureValue(const SemanticFeature | |
| if (constraint != nullptr) { | ||
| return new SpeakableString(*npc(constraint)); | ||
| } | ||
| const auto displayValueResult = getDisplayValue(true); | ||
| if (displayValueResult) { | ||
| const auto defaultFeatureFunction = npc(getModel())->getDefaultFeatureFunction(feature); | ||
| ::std::unique_ptr<SpeakableString> computedValue; | ||
| ::std::unique_ptr<SpeakableString> baseValue; | ||
| if (defaultFeatureFunction != nullptr) { | ||
| computedValue.reset(npc(defaultFeatureFunction)->getFeatureValue(*displayValueResult, constraints)); | ||
| baseValue.reset(npc(defaultFeatureFunction)->getFeatureValue(defaultDisplayValue, constraints)); | ||
| } | ||
| const auto& displayConstraintMap = displayValueResult->getConstraintMap(); | ||
| auto displayConstraint = displayConstraintMap.find(feature); | ||
| if (displayConstraint != displayConstraintMap.end()) { | ||
| auto numberFeature = npc(getModel())->getFeature(u"number"); | ||
| if (feature.getName() == u"gender" && baseValue && numberFeature != nullptr && displayConstraintMap.find(*npc(numberFeature)) != displayConstraintMap.end()) { | ||
| return baseValue.release(); | ||
| } | ||
| return new SpeakableString(displayConstraint->second); | ||
| } | ||
| if (computedValue) { | ||
| return computedValue.release(); | ||
| } | ||
| if (baseValue) { | ||
| return baseValue.release(); | ||
| } | ||
| } | ||
| const auto& initialConstraintMap = defaultDisplayValue.getConstraintMap(); | ||
| auto initialConstraint = initialConstraintMap.find(feature); | ||
| if (initialConstraint != initialConstraintMap.end()) { | ||
| return new SpeakableString(initialConstraint->second); | ||
| } | ||
|
||
| auto defaultFeatureFunction = npc(getModel())->getDefaultFeatureFunction(feature); | ||
| if (defaultFeatureFunction != nullptr) { | ||
| const auto displayValueResult = getDisplayValue(true); | ||
| if (displayValueResult) { | ||
| return npc(defaultFeatureFunction)->getFeatureValue(*displayValueResult, constraints); | ||
| if (auto fallbackValue = ::std::unique_ptr<SpeakableString>(npc(defaultFeatureFunction)->getFeatureValue(defaultDisplayValue, constraints))) { | ||
| return fallbackValue.release(); | ||
| } | ||
| } | ||
| return nullptr; | ||
|
|
@@ -76,11 +105,7 @@ ::std::optional<DisplayValue> InflectableStringConcept::getDisplayValue(bool all | |
| { | ||
| auto defaultDisplayFunction = npc(getModel())->getDefaultDisplayFunction(); | ||
| if (defaultDisplayFunction != nullptr && !constraints.empty()) { | ||
| ::std::map<SemanticFeature, ::std::u16string> constraintMap; | ||
| if (!value.speakEqualsPrint()) { | ||
| constraintMap.emplace(*npc(getSpeakFeature()), value.getSpeak()); | ||
| } | ||
| SemanticFeatureModel_DisplayData displayData({DisplayValue(value.getPrint(), constraintMap)}); | ||
| SemanticFeatureModel_DisplayData displayData({defaultDisplayValue}); | ||
| ::std::unique_ptr<DisplayValue> returnVal(npc(defaultDisplayFunction)->getDisplayValue(displayData, constraints, allowInflectionGuess)); | ||
| if (returnVal != nullptr) { | ||
| return *returnVal; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grhoten
Was this the expected behavior in this function? If not, could you please point out where I am going wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Within the DictionaryLookupFunction, you're only returning the grammeme value. This does not need to change.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay sure I wanted to know exactly what I need to do, based on your previous comment I came up with this commit, could you please tell what is expected to make the tests pass so that i could implement the same and further add tests in InfectableStringConceptTest-c.cpp as well to complete this task ?