Skip to content

Commit c41ec8c

Browse files
committed
Done
1 parent 9c8ba42 commit c41ec8c

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

inflection/src/inflection/dialog/InflectableStringConcept-c.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
* Copyright 2021-2024 Apple Inc. All rights reserved.
33
*/
44
#include <inflection/dialog/InflectableStringConcept.h>
5-
5+
#include <inflection/npc.hpp>
66
#include <inflection/dialog/InflectableStringConcept.hpp>
77
#include <inflection/dialog/SemanticFeatureConcept.h>
88
#include <inflection/exception/ClassCastException.hpp>
99
#include <inflection/util/ULocale.hpp>
1010
#include <inflection/dialog/SemanticFeature.hpp>
11+
#include <inflection/dialog/SemanticUtils.hpp>
12+
#include <inflection/dialog/SemanticFeatureModel.hpp>
1113
#include <inflection/util/TypeConversionUtils.hpp>
1214
#include <inflection/util/Validate.hpp>
1315

16+
1417
INFLECTION_CAPI IDSemanticFeatureConcept* iinf_toSemanticFeatureConcept(IDInflectableStringConcept* thisObject, UErrorCode*)
1518
{
1619
return (IDSemanticFeatureConcept*)thisObject;
@@ -49,21 +52,16 @@ iinf_create(const IDSemanticFeatureModel* model, const IDSpeakableString* value,
4952
}
5053

5154
INFLECTION_CAPI IDInflectableStringConcept*
52-
iinf_createWithConstraints(const IDSemanticFeatureModel* model, const IDSpeakableString* value,
53-
const ::inflection::dialog::SemanticFeature* features, const char16_t** values, int32_t SemanticFeaturesLen, UErrorCode* status) {
55+
iinf_createWithDefaults(const IDSemanticFeatureModel* model, const IDSpeakableString* value,
56+
const IDDisplayValue_Constraint* defaultConstraints, int32_t defaultConstraintsLen, UErrorCode* status) {
5457
if (status != nullptr && U_SUCCESS(*status)) {
5558
try {
56-
inflection::util::Validate::notNull(value);
57-
58-
::std::map< ::inflection::dialog::SemanticFeature, ::std::u16string> initialConstraints;
59-
for (int32_t i = 0; i < SemanticFeaturesLen; ++i) {
60-
initialConstraints.emplace(features[i], ::std::u16string(values[i]));
61-
}
59+
auto defaultConstraintsMap(inflection::dialog::SemanticUtils::to_constraintMap(*npc((const inflection::dialog::SemanticFeatureModel*)model), defaultConstraints, defaultConstraintsLen));
6260

6361
return (IDInflectableStringConcept*) new ::inflection::dialog::InflectableStringConcept(
6462
(const ::inflection::dialog::SemanticFeatureModel*)model,
6563
*((const ::inflection::dialog::SpeakableString*)value),
66-
initialConstraints
64+
defaultConstraintsMap
6765
);
6866
}
6967
catch (const ::std::exception& e) {

inflection/src/inflection/dialog/InflectableStringConcept.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <inflection/dialog/SpeakableString.h>
77
#include <inflection/dialog/SemanticFeatureConcept.h>
88
#include <inflection/dialog/SemanticFeatureModel.h>
9-
#include <inflection/dialog/SemanticFeature.hpp>
9+
#include <inflection/dialog/SemanticUtils.hpp>
1010
/**
1111
* An object that provides a way to format a word with additional grammatical category values or semantic features of a word for a given language.
1212
*/
@@ -39,15 +39,14 @@ INFLECTION_CAPI IDInflectableStringConcept* iinf_create(const IDSemanticFeatureM
3939
*
4040
* @param model - The semantic feature model required to initialize the concept.
4141
* @param value - The speakable string to convert to a concept
42-
* @param features - The initial semantic features to apply to the concept
43-
* @param values - The initial corresponding values for the semantic features
44-
* @param SemanticFeaturesLen - The number of semantic features and values provided
42+
* @param defaultConstraints - The initial defaultConstraints to apply to the concept
43+
* @param defaultConstraintsLen - The number of semantic features and values provided
4544
* @param status Must be a valid pointer to an error code value,
4645
* which must not indicate a failure before the function call.
4746
* This is set to a failure when a failure has occurred during execution.
4847
*/
49-
INFLECTION_CAPI IDInflectableStringConcept* iinf_createWithConstraints(const IDSemanticFeatureModel* model, const IDSpeakableString* value,
50-
const inflection::dialog::SemanticFeature* features, const char16_t** values, int32_t SemanticFeaturesLen, UErrorCode* status);
48+
INFLECTION_CAPI IDInflectableStringConcept* iinf_createWithDefaults(const IDSemanticFeatureModel* model, const IDSpeakableString* value,
49+
const IDDisplayValue_Constraint* defaultConstraints, int32_t defaultConstraintsLen, UErrorCode* status);
5150
/**
5251
* Destructor
5352
*/

inflection/src/inflection/dialog/PronounConcept.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ PronounConcept::PronounConcept(const SemanticFeatureModel& model, const ::std::v
211211
if (pronounData->numValues() == 0) {
212212
throw ::inflection::exception::IllegalArgumentException(u"Display data can not be empty.");
213213
}
214+
214215
for (const auto &[semanticFeature, grammeme]: defaultConstraints) {
215216
this->defaultConstraints.emplace(semanticFeature.getName(), grammeme);
216217
}

0 commit comments

Comments
 (0)