|
Inflection
Morphology Inflection
|
The MF2Factory provides factory methods to create custom functions to work with the icu::message2 library. The intended usage is to create an icu::message2::Function and use it with icu::message2::MFFunctionRegistry::Builder to construct a custom function registry to build a MessageFormatter with MessageFormatter::Builder.
More...
#include <MF2Factory.hpp>
Public Types | |
| enum class | OutputMode { PLAIN , SSML } |
Static Public Member Functions | |
| static icu::message2::Function * | createInflectFunction (OutputMode mode=OutputMode::PLAIN) |
| static icu::message2::Function * | createNumeralFunction (OutputMode mode=OutputMode::PLAIN) |
| static icu::message2::Function * | createQuantifyFunction (OutputMode mode=OutputMode::PLAIN) |
| static icu::message2::Function * | createListFunction (OutputMode mode=OutputMode::PLAIN) |
| static icu::message2::Function * | createPronounFunction (OutputMode mode=OutputMode::PLAIN) |
The MF2Factory provides factory methods to create custom functions to work with the icu::message2 library. The intended usage is to create an icu::message2::Function and use it with icu::message2::MFFunctionRegistry::Builder to construct a custom function registry to build a MessageFormatter with MessageFormatter::Builder.
For example:
auto customRegistry = icu::message2::MFFunctionRegistry::Builder(errorCode)
.adoptFunction(FunctionName("i:inflect"),
MF2Factory::createInflectFunction(), errorCode)
.build();
UParseError pe;
auto mf1 = icu::message2::MessageFormatter::Builder(errorCode)
.setFunctionRegistry(customRegistry)
.setLocale(Locale::forLanguageTag("es-MX", errorCode))
.setPattern("Location is {$name :i:inflect hello=world \
definiteness=definite number=plural \
gender=feminine}",
pe, errorCode)
.build(errorCode);
auto mf2 = icu::message2::MessageFormatter::Builder(errorCode)
.setFunctionRegistry(customRegistry)
.setLocale(Locale::forLanguageTag("es-MX", errorCode))
.setPattern(".local $gender = {$name :i:inflect \
feature=gender} \
.local $number = {$name :i:inflect \
feature=number} \
.match $gender $number \
feminine singular {{Feminine Singular {$name}}}\
masculine singular {{Masculine Singular {$name}}}\
* * {{other {$name} }}\n",
pe, errorCode)
.build(errorCode);
Definition at line 54 of file MF2Factory.hpp.
|
strong |
Controls how formatters serialize their result: PLAIN emits the print form only; SSML emits Speech Synthesis Markup Language (SSML) markup — a <sub alias="..."> element when print differs from speak.
Definition at line 63 of file MF2Factory.hpp.
|
static |
Create an implementation of icu::message2::Function*, based on the inflection library, which can be passed to icu::message2::MFFunctionRegistry::Builder::adoptFunction to register a custom function.
|
static |
Create a Function for the :i:list function (array → plain/and/or list).
|
static |
Create an implementation of icu::message2::Function* for the :i:numeral function (number formatting), based on the inflection library, which can be passed to icu::message2::MFFunctionRegistry::Builder::adoptFunction to register a custom function.
|
static |
Create a Function for the :i:pronoun function.
|
static |
Create a Function for the :i:quantify function (count + unit agreement).