# Regex note: (?! ... ) is a negative lookahead. Succeed if the pattern is not present.
set +o pipefail && make doc 2>&1 | tee doxygen.log && ( ! grep -P 'warning:(?! .* file .?Doxyfile)' doxygen.log )
- # Java7 ICU4J build and unit test
- java7-icu4j-build-and-test:
+ # Java8 ICU4J build and unit test
+ java8-icu4j-build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout and setup
lfs: true
- name: Checkout lfs objects
run: git lfs pull
- - uses: actions/setup-java@v1
+ - uses: actions/setup-java@v3
with:
+ distribution: 'temurin'
java-version: '8'
- - name: Cache for Java 7 tarball
- id: cache-java7
- uses: actions/cache@v2
- with:
- path: java7-tarball
- key: ${{ runner.os }}-java7-tarball
- - name: Download Java 7
- if: steps.cache-java7.outputs.cache-hit != 'true'
- run: |
- mkdir -p java7-tarball
- download_url="https://download.java.net/openjdk/jdk7u75/ri/openjdk-7u75-b13-linux-x64-18_dec_2014.tar.gz"
- wget -O java7-tarball/java_package.tar.gz $download_url
- pushd java7-tarball
- gunzip java_package.tar.gz
- tar xvf java_package.tar
- popd
- - name: Configure Ant build to use Java 7 JRE
- run: |
- echo "java7.bootclasspath" > $RUNNER_TEMP/draft
- ls java7-tarball/java-se-7u75-ri/jre/lib/*.jar|paste -sd ":" - >> $RUNNER_TEMP/draft
- paste -sd "=" < $RUNNER_TEMP/draft > icu4j/build-local.properties
- name: ICU4J
run: |
cd icu4j;
lfs: true
- name: Checkout lfs objects
run: git lfs pull
- - uses: actions/setup-java@v1
+ - uses: actions/setup-java@v3
with:
+ distribution: 'temurin'
java-version: '11'
- name: ICU4J
run: |
lfs: true
- name: Checkout lfs objects
run: git lfs pull
- - uses: actions/setup-java@v1
+ - uses: actions/setup-java@v3
with:
+ distribution: 'temurin'
java-version: '16'
- name: ICU4J
run: |
lfs: true
- name: Checkout lfs objects
run: git lfs pull
- - uses: actions/setup-java@v1
+ - uses: actions/setup-java@v3
with:
+ distribution: 'temurin'
java-version: '11'
- name: Config LSTM and Rebuild data jar
run: |
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.junit.Test;
import org.junit.runner.RunWith;
main: for (ULocale locale : factory.getAvailableULocales()) {
PluralRules rules = factory.forLocale(locale);
Map<String, PluralRules> keywordToRule = new HashMap<>();
- Collection<DecimalQuantitySamples> samples = new LinkedHashSet<>();
+ // get the set of all rule samples from all of the keywords of the locale's rule
+ Set<DecimalQuantitySamples> samples =
+ rules.getKeywords()
+ .stream()
+ .flatMap(keyword -> {
+ return Arrays.stream(SampleType.values())
+ .map(sampleType -> rules.getDecimalSamples(keyword, sampleType));
+ })
+ .filter(Objects::nonNull)
+ .collect(Collectors.toSet());
+
+ // take the rule substring per keyword, and create a map keyed by keyword for a new rules object of that rule substring
for (String keyword : rules.getKeywords()) {
- for (SampleType sampleType : SampleType.values()) {
- DecimalQuantitySamples samples2 = rules.getDecimalSamples(keyword, sampleType);
- if (samples2 != null) {
- samples.add(samples2);
- }
- }
if (keyword.equals("other")) {
continue;
}
}
Map<DecimalQuantity, String> collisionTest = new LinkedHashMap();
- for (DecimalQuantitySamples sample3 : samples) {
- Set<DecimalQuantitySamplesRange> samples2 = sample3.getSamples();
- if (samples2 == null) {
- continue;
- }
- for (DecimalQuantitySamplesRange sample : samples2) {
- for (int i = 0; i < 1; ++i) {
- DecimalQuantity item = i == 0 ? sample.start : sample.end;
- collisionTest.clear();
- for (Entry<String, PluralRules> entry : keywordToRule.entrySet()) {
- PluralRules rule = entry.getValue();
- String foundKeyword = rule.select(item);
- if (foundKeyword.equals("other")) {
- continue;
- }
- String old = collisionTest.get(item);
- if (old != null) {
- errln(locale + "\tNon-unique rules: " + item + " => " + old + " & " + foundKeyword);
- rule.select(item);
- } else {
- collisionTest.put(item, foundKeyword);
- }
- }
+
+ // get all of the sample ranges from all of the samples
+ Stream<DecimalQuantitySamplesRange> ranges = samples.stream()
+ .map(DecimalQuantitySamples::getSamples)
+ .filter(Objects::nonNull)
+ .flatMap(Set::stream);
+
+ // get all of the sample values at the endpoints of each sample range
+ Stream<DecimalQuantity> items = ranges.flatMap(range -> {
+ return Arrays.stream(new DecimalQuantity[] {range.start, range.end});
+ });
+
+ items.forEach(item -> {
+ collisionTest.clear();
+ for (Entry<String, PluralRules> entry : keywordToRule.entrySet()) {
+ PluralRules rule = entry.getValue();
+ String foundKeyword = rule.select(item);
+ if (foundKeyword.equals("other")) {
+ continue;
+ }
+ String old = collisionTest.get(item);
+ if (old != null) {
+ errln(locale + "\tNon-unique rules: " + item + " => " + old + " & " + foundKeyword);
+ rule.select(item);
+ } else {
+ collisionTest.put(item, foundKeyword);
}
}
- }
+ });
}
}