RBNF rule semantics for a ruleset when there is no negative number rule
Philippe Verdy
verdy_p at wanadoo.fr
Fri Dec 2 10:51:26 CST 2016
Additionally the "ordinal number" are very strange if you lok for them with
negative values. I think we are in a very fuzzy use case: ordinals have
only been really tested for integers higher than 0, exclusing negative
numbers, zero, and fractional parts.
2016-12-02 17:48 GMT+01:00 Philippe Verdy <verdy_p at wanadoo.fr>:
> But in fact this negative rule is inherited from the default locale, which
> will insert the negative sign. You should then find a matching
> negative-number rule in the inherited locales.
>
> 2016-12-02 17:47 GMT+01:00 Philippe Verdy <verdy_p at wanadoo.fr>:
>
>> Note that there should be a negative-number rule there to format the sign
>> and separately the absolute value 50.
>>
>> 2016-12-02 17:45 GMT+01:00 Philippe Verdy <verdy_p at wanadoo.fr>:
>>
>>> rule for "4" matches the "Binary-search the rule list for the rule with
>>> the highest base value less than or equal to the number.", in fact all
>>> rules for "0", "3" and "4" have a base value less than or equal to the
>>> number 50. The binary search will point you just above rule for "4", which
>>> is the highest base value to use.
>>>
>>> 2016-12-02 10:52 GMT+01:00 Kip Cole <kipcole9 at gmail.com>:
>>>
>>>> I am writing some software using the CLDR. I am stuck on working out
>>>> the right semantics for formatting a number using RBNF and there is no
>>>> matching rule within a specified ruleset.
>>>>
>>>> For example (I’m writing this in Elixir but I think the intent is
>>>> clear) formatting the negative integer -50 in the locale “hr”:
>>>>
>>>> iex> Cldr.Rbnf.Spellout.spellout_ordinal_neuter(-50, "hr”)
>>>>
>>>> returns an error because in the locale “hr”, the ruleset for
>>>> spellout-ordinal-neuter has the following rules (in 30.0.2, using the json
>>>> github content):
>>>>
>>>> "%spellout-ordinal-neuter": {
>>>> "0": "=%%spellout-ordinal-base=o;",
>>>> "3": "=%%spellout-ordinal-base=e;",
>>>> "4": "=%%spellout-ordinal-base=o;"
>>>> }
>>>>
>>>> So that by my understanding, a negative number can’t be formatted in
>>>> this ruleset for this locale. The nearest understanding I can get is from
>>>> http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html
>>>> which says:
>>>>
>>>> • If the number is negative, use the negative-number rule.
>>>> • If the number has a fractional part and is greater than 1,
>>>> use the improper fraction rule.
>>>> • If the number has a fractional part and is between 0 and 1,
>>>> use the proper fraction rule.
>>>> • Binary-search the rule list for the rule with the highest
>>>> base value less than or equal to the number. If that rule has two
>>>> substitutions, its base value is not an even multiple of its divisor, and
>>>> the number is an even multiple of the rule's divisor, use the rule that
>>>> precedes it in the rule list. Otherwise, use the rule itself.
>>>>
>>>> Given a negative integer in this context then:
>>>>
>>>> 1. There is no negative number rule
>>>> 2. There is no rule that satisfies "Binary-search the rule list for the
>>>> rule with the highest base value less than or equal to the number.”
>>>>
>>>> Are then any additional semantics intended to cover this case or is an
>>>> error the appropriate response?
>>>>
>>>> Many thanks.
>>>> _______________________________________________
>>>> CLDR-Users mailing list
>>>> CLDR-Users at unicode.org
>>>> http://unicode.org/mailman/listinfo/cldr-users
>>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://unicode.org/pipermail/cldr-users/attachments/20161202/bef3ff34/attachment.html>
More information about the CLDR-Users
mailing list