Add PluralRules.getSamples

Description

Deleted Component: formatting

I'm proposing the following single-method addition:

The initial implementation just cycles through 256 elements adding any that occur, and bailing when max occurs. It also checks for fractions, adding at least one if possible (it only checks certain tenths: i + ((i % 9) + 1) / 10.0). A smarter implementation could be done down the line.

Issues:

  • if we removed the max parameter, and just hard-coded the max (at say 10), then we could compute the list statically for each distinct rulelist.

  • in C++, we'd deposit the results into an array, with the normal ICU idiom.

  • theoretically, one of the keywords could only apply above 256, or only be solitary under that.

Here is a test code run, with verbose on.

Activity

Show:
TracBot
June 30, 2018, 11:43 PM
Trac Comment 1 by —2011-02-02T19:45:45.595Z

After discussion:

TracBot
June 30, 2018, 11:43 PM
Trac Comment 3 by —2011-03-01T19:47:05.490Z

It's a bit inefficient to do this once per keyword, it's better to do it all in one go. In Java we could simply return a map, but in C there's no good API, unfortunately.

Since this proposes removing the 'max' parameter, though, we can simply cache the result internally and use it on subsequent calls. I'm going to default max to 3 since I see no good reason to provide more values.

TracBot
June 30, 2018, 11:43 PM
Trac Comment 4 by —2011-03-02T01:33:52.722Z

Modified ICU4J version and submitted.

TracBot
June 30, 2018, 11:43 PM
Trac Comment 7 by —2011-03-04T01:36:16.097Z

Opened a new bug for the ICU4C portion.

TracBot
June 30, 2018, 11:43 PM
Trac Comment 9 by —2016-10-05T23:13:36.787Z

Milestone 4.7.1 deleted

Fixed

Assignee

Douglas Felt

Reporter

Mark Davis

Components

None

Labels

None

Reviewer

None

Priority

major

Time Needed

Days

Fix versions