Inflection
Morphology Inflection
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
inflection::dialog::NumberConcept Class Reference

Provides representation of numerics as lexical tokens, such as ordinals or cardinals. More...

#include <NumberConcept.hpp>

+ Inheritance diagram for inflection::dialog::NumberConcept:

Public Member Functions

virtual NumberConceptgetAbsolute () const
 
virtual NumberConceptminFractionDigits (int32_t min) const
 
virtual NumberConceptmaxFractionDigits (int32_t max) const
 
virtual NumberConceptmaxFractionDigitsAboveOne (int32_t given) const
 
virtual int32_t getMaximumFractionDigits () const
 
virtual NumberConceptminIntegerDigits (int32_t min) const
 
virtual NumberConceptmaxIntegerDigits (int32_t max) const
 
virtual NumberConceptgrouping (bool grouping) const
 
virtual NumberConceptroundUp () const
 
virtual NumberConceptroundDown () const
 
virtual NumberConceptroundHalfUp () const
 
virtual NumberConceptroundHalfDown () const
 
virtual NumberConceptroundCeiling () const
 
virtual NumberConceptroundFloor () const
 
virtual bool getIsNegative () const
 
virtual bool hasFraction () const
 
virtual const ::inflection::util::ULocalegetLanguage () const
 
virtual const ::inflection::util::ULocalegetRegionLocale () const
 
::std::u16string toString () const override
 
SpeakableStringtoSpeakableString () const override
 
virtual ::std::u16string getAsWords () const
 
virtual ::std::u16string asWords (const ::std::u16string &variant) const
 
virtual SpeakableString getAsSpokenWords () const
 
virtual SpeakableString asSpokenWords (const ::std::u16string &variant) const
 
virtual SpeakableString getAsDigits () const
 
virtual ::std::u16string getAsOrdinalDigits () const
 
virtual ::std::u16string asDigits (const ::std::u16string &variant) const
 
bool operator== (const NumberConcept &o) const
 
std::size_t operator() (const NumberConcept &o) const noexcept
 
std::partial_ordering operator<=> (const NumberConcept &o) const
 
int64_t longValue () const
 
double doubleValue () const
 
 NumberConcept (int64_t value, const ::inflection::util::ULocale &language, const ::inflection::util::ULocale &regionLocale)
 
 NumberConcept (double value, const ::inflection::util::ULocale &language, const ::inflection::util::ULocale &regionLocale)
 
 NumberConcept (const NumberConcept &original)
 
- Public Member Functions inherited from inflection::dialog::SpeakableConcept
 ~SpeakableConcept () override
 
- Public Member Functions inherited from inflection::Object
virtual ::std::u16string toString () const
 
virtual ~Object ()
 

Detailed Description

Provides representation of numerics as lexical tokens, such as ordinals or cardinals.

An object that provides representation of numerics.

As with the other concepts within Siri, NumberConcept provides utility functions, grammatical rules, and lexical representation for a real-world or linguistic concept. In this case: generic numerals.

Definition at line 21 of file NumberConcept.hpp.

Constructor & Destructor Documentation

◆ NumberConcept() [1/3]

inflection::dialog::NumberConcept::NumberConcept ( int64_t  value,
const ::inflection::util::ULocale language,
const ::inflection::util::ULocale regionLocale 
)

Construct a NumberConcept.

Parameters
valuea 64-bit value
languageThis locale is primarily used for the speak property of a SpeakableString.
regionLocaleThis locale is primarily used for the print property of a SpeakableString.

◆ NumberConcept() [2/3]

inflection::dialog::NumberConcept::NumberConcept ( double  value,
const ::inflection::util::ULocale language,
const ::inflection::util::ULocale regionLocale 
)

Construct a NumberConcept.

Parameters
valuean IEEE 754 double value.
languageThis locale is primarily used for the speak property of a SpeakableString.
regionLocaleThis locale is primarily used for the print property of a SpeakableString.

◆ NumberConcept() [3/3]

inflection::dialog::NumberConcept::NumberConcept ( const NumberConcept original)

Copy constructor

Member Function Documentation

◆ asDigits()

virtual ::std::u16string inflection::dialog::NumberConcept::asDigits ( const ::std::u16string &  variant) const

Format the number as ordinal digits using the language with the requested variant. For example, you can request the Spanish forms for 1º. and 1ª.

Parameters
variantCheck out the complete list of rule names see https://st.unicode.org/cldr-apps/numbers.jsp?type=OrdinalRules for details.

◆ asSpokenWords()

virtual SpeakableString inflection::dialog::NumberConcept::asSpokenWords ( const ::std::u16string &  variant) const
virtual

Format the number with a printable and speakable form. The print part of the SpeakableString is the same as asDigits(). The speak part of the SpeakableString is the same as asWords(variant).

Parameters
variantCheck out the complete list of rule names see https://st.unicode.org/cldr-apps/numbers.jsp for details.

◆ asWords()

virtual ::std::u16string inflection::dialog::NumberConcept::asWords ( const ::std::u16string &  variant) const

Format the number with words with the variant rule name. The words are based on the language used to construct this object.

Parameters
variantCheck out the complete list of rule names see https://st.unicode.org/cldr-apps/numbers.jsp for details.

◆ doubleValue()

double inflection::dialog::NumberConcept::doubleValue ( ) const

Returns the value of this NumberConcept as a double number.

◆ getAbsolute()

virtual NumberConcept * inflection::dialog::NumberConcept::getAbsolute ( ) const
virtual

Return the absolute value of this NumberConcept.

Returns
A new NumberConcept.

◆ getAsDigits()

virtual SpeakableString inflection::dialog::NumberConcept::getAsDigits ( ) const
virtual

Format the number with digits using the region locale. The speak part may contain words or digits for the given language when the language is not the same as the region locale or the TTS system can not properly pronounce the printed form.

◆ getAsOrdinalDigits()

virtual ::std::u16string inflection::dialog::NumberConcept::getAsOrdinalDigits ( ) const

Format the number as ordinal digits using the language. For example, the number would be formatted as 1st, 2nd and 3rd in English.

See also
https://st.unicode.org/cldr-apps/numbers.jsp?type=OrdinalRules

◆ getAsSpokenWords()

virtual SpeakableString inflection::dialog::NumberConcept::getAsSpokenWords ( ) const
virtual

Format the number with a printable and speakable form. The print part of the SpeakableString is the same as asDigits(). The speak part of the SpeakableString is the same as asWords().

◆ getAsWords()

virtual ::std::u16string inflection::dialog::NumberConcept::getAsWords ( ) const

Format the number with words. The words are based on the language used to construct this object.

◆ getIsNegative()

virtual bool inflection::dialog::NumberConcept::getIsNegative ( ) const
virtual

Returns true when the number is negative.

◆ getLanguage()

virtual const ::inflection::util::ULocale & inflection::dialog::NumberConcept::getLanguage ( ) const
virtual

Returns the language used to format the speakable part of a SpeakableString.

◆ getMaximumFractionDigits()

virtual int32_t inflection::dialog::NumberConcept::getMaximumFractionDigits ( ) const
virtual

Get the maximum number of digits to show after the decimal point

◆ getRegionLocale()

virtual const ::inflection::util::ULocale & inflection::dialog::NumberConcept::getRegionLocale ( ) const
virtual

Returns the locale used to format the printable part of a SpeakableString.

◆ grouping()

virtual NumberConcept * inflection::dialog::NumberConcept::grouping ( bool  grouping) const
virtual

Is grouping shown? For example: 1,234.56 turns into 1234.56 when grouping is false.

Returns
A new NumberConcept.

◆ hasFraction()

virtual bool inflection::dialog::NumberConcept::hasFraction ( ) const
virtual

Returns true when the value can not be represented as an integer without rounding.

◆ longValue()

int64_t inflection::dialog::NumberConcept::longValue ( ) const

Returns the value of this NumberConcept as a 64-bit number.

◆ maxFractionDigits()

virtual NumberConcept * inflection::dialog::NumberConcept::maxFractionDigits ( int32_t  max) const
virtual

Set the maximum number of digits to show after the decimal point for a new NumberConcept. For example: 12.3456 turns into 12.35 when set to 2.

Returns
A new NumberConcept.

◆ maxFractionDigitsAboveOne()

virtual NumberConcept * inflection::dialog::NumberConcept::maxFractionDigitsAboveOne ( int32_t  given) const
virtual

For values greater than 1.0, always have given fractional digits. For numbers between 1.0 and 0.0, always have at least given non-zero digits, no matter how many leading zeros are needed. Omit the trailing zeros of the fractional part.

◆ maxIntegerDigits()

virtual NumberConcept * inflection::dialog::NumberConcept::maxIntegerDigits ( int32_t  max) const
virtual

Set the maximum number of digits to show before the decimal point for a new NumberConcept.

Returns
A new NumberConcept.

◆ minFractionDigits()

virtual NumberConcept * inflection::dialog::NumberConcept::minFractionDigits ( int32_t  min) const
virtual

Set the minimum number of digits to show after the decimal point for a new NumberConcept. For example: 12 turns into 12.00 when set to 2.

Returns
A new NumberConcept.

◆ minIntegerDigits()

virtual NumberConcept * inflection::dialog::NumberConcept::minIntegerDigits ( int32_t  min) const
virtual

Set the minimum number of digits to show before the decimal point for a new NumberConcept.

Returns
A new NumberConcept.

◆ operator()()

std::size_t inflection::dialog::NumberConcept::operator() ( const NumberConcept o) const
noexcept
Returns
Returns the long value of this NumberConcept cast as an size_t.

◆ operator<=>()

std::partial_ordering inflection::dialog::NumberConcept::operator<=> ( const NumberConcept o) const

String compares the order of the NumberConcept objects. Formatting differences are not considered.

Parameters
oThe object to be compared with this.

◆ operator==()

bool inflection::dialog::NumberConcept::operator== ( const NumberConcept o) const

Returns true when both NumberConcept objects are the same value. Formatting differences are not considered.

◆ roundCeiling()

virtual NumberConcept * inflection::dialog::NumberConcept::roundCeiling ( ) const
virtual

Rounds any fraction towards positive infinity.

Returns
A new NumberConcept.

◆ roundDown()

virtual NumberConcept * inflection::dialog::NumberConcept::roundDown ( ) const
virtual

Round toward zero. Use maxFractionDigits to round at a specific place after the decimal point.

Returns
A new NumberConcept.

◆ roundFloor()

virtual NumberConcept * inflection::dialog::NumberConcept::roundFloor ( ) const
virtual

Rounds any fraction towards negative infinity.

Returns
A new NumberConcept.

◆ roundHalfDown()

virtual NumberConcept * inflection::dialog::NumberConcept::roundHalfDown ( ) const
virtual

Round to closest number, preferring toward zero if halfway in between. Use maxFractionDigits to round at a specific place after the decimal point.

Returns
A new NumberConcept.

◆ roundHalfUp()

virtual NumberConcept * inflection::dialog::NumberConcept::roundHalfUp ( ) const
virtual

Round to closest number, preferring away from zero if halfway in between. Use maxFractionDigits to round at a specific place after the decimal point.

Returns
A new NumberConcept.

◆ roundUp()

virtual NumberConcept * inflection::dialog::NumberConcept::roundUp ( ) const
virtual

Round away from zero. Use maxFractionDigits to round at a specific place after the decimal point.

Returns
A new NumberConcept.

◆ toSpeakableString()

SpeakableString * inflection::dialog::NumberConcept::toSpeakableString ( ) const
overridevirtual

Return a SpeakableString of this NumberConcept. The behavior is the same as getAsDigits().

Implements inflection::dialog::SpeakableConcept.

◆ toString()

::std::u16string inflection::dialog::NumberConcept::toString ( ) const
override

Return a debuggable form of this NumberConcept.


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