Inflection
Morphology Inflection
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
inflection::message2::MF2Factory Class Reference

The MF2Factory provide factory method to create custom formatter and selector factory to work with icu::message2 library. The intend usage is to creat icu::message2::FormatterFactory or icu::message2::SelectorFactory and use it with icu::message2::MFFunctionRegistry::Builder to construct a custom function registry to build MessageFormatter with MessageFormatter::Builder. More...

#include <MF2Factory.hpp>

Public Types

enum class  OutputMode { PLAIN , SSML }
 

Static Public Member Functions

static icu::message2::FormatterFactory * createInflectFormatterFactory (OutputMode mode=OutputMode::PLAIN)
 
static icu::message2::SelectorFactory * createInflectSelectorFactory ()
 
static icu::message2::FormatterFactory * createNumeralFormatterFactory (OutputMode mode=OutputMode::PLAIN)
 
static icu::message2::FormatterFactory * createQuantifyFormatterFactory (OutputMode mode=OutputMode::PLAIN)
 
static icu::message2::FormatterFactory * createListFormatterFactory (OutputMode mode=OutputMode::PLAIN)
 
static icu::message2::FormatterFactory * createPronounFormatterFactory (OutputMode mode=OutputMode::PLAIN)
 
static icu::message2::SelectorFactory * createPronounSelectorFactory ()
 

Detailed Description

The MF2Factory provide factory method to create custom formatter and selector factory to work with icu::message2 library. The intend usage is to creat icu::message2::FormatterFactory or icu::message2::SelectorFactory and use it with icu::message2::MFFunctionRegistry::Builder to construct a custom function registry to build MessageFormatter with MessageFormatter::Builder.

For example:

auto customRegistry = icu::message2::MFFunctionRegistry::Builder(errorCode)
         .adoptFormatter(FunctionName("inflect"),
                         MF2Factory::createInflectFormatterFactory(), errorCode)
         .adoptSelector(FunctionName("inflect"),
                         MF2Factory::createInflectSelectorFactory(), errorCode)
         .build();

UParseError pe;
auto mf1 = icu::message2::MessageFormatter::Builder(errorCode)
             .setFunctionRegistry(customRegistry)
             .setLocale(Locale::forLanguageTag("es-MX", errorCode))
             .setPattern("Location is {$name :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 :inflect \
                                            feature=gender} \
                          .local $number = {$name :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 57 of file MF2Factory.hpp.

Member Enumeration Documentation

◆ OutputMode

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.

See also
https://www.w3.org/TR/speech-synthesis/

Definition at line 66 of file MF2Factory.hpp.

Member Function Documentation

◆ createInflectFormatterFactory()

static icu::message2::FormatterFactory * inflection::message2::MF2Factory::createInflectFormatterFactory ( OutputMode  mode = OutputMode::PLAIN)
static

Create an implementation of icu::message2::FormatterFactory*, based on the infleciton library, which can be passed to icu::messsage2::MFFunctionRegistry::Builder::adoptFormatter to register a custom formatter factory.

◆ createInflectSelectorFactory()

static icu::message2::SelectorFactory * inflection::message2::MF2Factory::createInflectSelectorFactory ( )
static

Create an implementation of icu::message2::SelectorFactory*, based on the infleciton library, which can be passed to icu::messsage2::MFFunctionRegistry::Builder::adoptSelector to register a custom selector factory.

◆ createListFormatterFactory()

static icu::message2::FormatterFactory * inflection::message2::MF2Factory::createListFormatterFactory ( OutputMode  mode = OutputMode::PLAIN)
static

Create a FormatterFactory for the :list function (array → plain/and/or list).

◆ createNumeralFormatterFactory()

static icu::message2::FormatterFactory * inflection::message2::MF2Factory::createNumeralFormatterFactory ( OutputMode  mode = OutputMode::PLAIN)
static

Create an implementation of icu::message2::FormatterFactory* for the :numeral function (number formatting), based on the inflection library, which can be passed to icu::messsage2::MFFunctionRegistry::Builder::adoptFormatter to register a custom formatter factory.

◆ createPronounFormatterFactory()

static icu::message2::FormatterFactory * inflection::message2::MF2Factory::createPronounFormatterFactory ( OutputMode  mode = OutputMode::PLAIN)
static

Create a FormatterFactory for the :pronoun function.

◆ createPronounSelectorFactory()

static icu::message2::SelectorFactory * inflection::message2::MF2Factory::createPronounSelectorFactory ( )
static

Create a SelectorFactory for the :pronoun function.

◆ createQuantifyFormatterFactory()

static icu::message2::FormatterFactory * inflection::message2::MF2Factory::createQuantifyFormatterFactory ( OutputMode  mode = OutputMode::PLAIN)
static

Create a FormatterFactory for the :quantify function (count + unit agreement).


The documentation for this class was generated from the following file: