source: josm/trunk/scripts/I18nSimilarStrings.java@ 13792

Last change on this file since 13792 was 13761, checked in by Don-vip, 6 years ago

see #16288 - replace similar i18n strings (removes 35 strings from Launchpad)

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1import java.util.ArrayList;
2import java.util.Collections;
3import java.util.List;
4
5import org.openstreetmap.josm.data.validation.tests.SimilarNamedWays;
6import org.openstreetmap.josm.tools.I18n;
7
8// License: GPL. For details, see LICENSE file.
9
10/**
11 * Finds similar strings in lang files to find potential duplicates in order to reduce translation workload.
12 */
13public final class I18nSimilarStrings {
14
15 /**
16 * Main.
17 * @param args not used
18 */
19 public static void main(String[] args) {
20 I18n.init();
21 List<String> strings = new ArrayList<>();
22 strings.addAll(I18n.getSingularTranslations().keySet());
23 strings.addAll(I18n.getPluralTranslations().keySet());
24 System.out.println("Loaded " + strings.size() + " core strings");
25 strings.removeIf(s -> s.length() <= 5);
26 System.out.println("Kept " + strings.size() + " core strings longer than 5 characters");
27 Collections.sort(strings);
28 for (int i = 0; i < strings.size(); i++) {
29 for (int j = i+1; j < strings.size(); j++) {
30 String a = strings.get(i);
31 String b = strings.get(j);
32 int d = SimilarNamedWays.getLevenshteinDistance(a, b);
33 if (d <= 2) {
34 System.err.println(": " + a + " <--> " + b);
35 }
36 }
37 }
38 System.out.println("Done!");
39 }
40}
Note: See TracBrowser for help on using the repository browser.