|
From: | Michele Locati |
Subject: | Re: [bug-gettext] Plural rule definitions |
Date: | Fri, 22 May 2015 11:25:29 +0200 |
Michele Locati <address@hidden> writes:
[...]
Yes, my intent was to make the output resemble the current style of
plural-table.c as much as possible, to make the initial diff smaller.
[...]
BTW, for samples, I plan to add a separate array, say
plural_sample_table to avoid confusion.
[...]
I hit on an algorithm:
- From all rules, find the largest modulo M (here 100)
- Prepare a bit vector with M elements and initialize it with zeros
- Loop over the rules
- For each value in the range [1, M], apply a rule, and flip the
corresponding bit if it evaluates true
- Stop if all bits are set
Maybe we can also omit rules which don't change the vector, but it seems
to work with the Russian case so far:
http://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-tools/src/cldr-plural-exp.c?h=wip/ueno/cldr-plural#n546
[Prev in Thread] | Current Thread | [Next in Thread] |