From 45d820412108d915ed2ecec16c84e8b96677abad Mon Sep 17 00:00:00 2001 From: crimean Date: Thu, 21 Feb 2019 14:16:25 +0300 Subject: [PATCH] Mute atilika.kuromoji --- OsmAnd-java/build.gradle | 3 +- .../osmand/util/TransliterationHelper.java | 49 ++++++------------- OsmAnd/build.gradle | 14 +++--- .../plus/render/MapRenderRepositories.java | 17 ++----- 4 files changed, 29 insertions(+), 54 deletions(-) diff --git a/OsmAnd-java/build.gradle b/OsmAnd-java/build.gradle index 564df1bb7d..42b45a78f0 100644 --- a/OsmAnd-java/build.gradle +++ b/OsmAnd-java/build.gradle @@ -89,7 +89,8 @@ dependencies { implementation 'org.apache.commons:commons-compress:1.17' implementation 'com.moparisthebest:junidecode:0.1.1' implementation 'com.vividsolutions:jts-core:1.14.0' - implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0' + // turn off for now + //implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0' implementation 'net.sf.kxml:kxml2:2.1.8' implementation fileTree(include: ['*.jar'], dir: 'libs') } diff --git a/OsmAnd-java/src/main/java/net/osmand/util/TransliterationHelper.java b/OsmAnd-java/src/main/java/net/osmand/util/TransliterationHelper.java index 45e99b080c..357899c1e2 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/TransliterationHelper.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/TransliterationHelper.java @@ -1,59 +1,41 @@ package net.osmand.util; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.atilika.kuromoji.ipadic.Token; -import com.atilika.kuromoji.ipadic.Tokenizer; import net.osmand.PlatformUtil; import net.sf.junidecode.Junidecode; + import org.apache.commons.logging.Log; public class TransliterationHelper { public final static Log LOG = PlatformUtil.getLog(TransliterationHelper.class); - public final static String DEFAULT = "default"; - public final static String JAPAN = "Japan"; - private static String countryName = DEFAULT; + private static boolean japanese; - private static Tokenizer tokenizer; - - private static Map katakanaMap = new HashMap<>(); + //private static Tokenizer tokenizer; + //private static Map katakanaMap = new HashMap<>(); private TransliterationHelper() { } - public static void setCountryName(String countryName) { - if (!countryName.equals(TransliterationHelper.countryName)) { - switch (countryName) { - case "Japan": { - TransliterationHelper.countryName = JAPAN; - break; - } - default: - TransliterationHelper.countryName = DEFAULT; - break; - } - } + public static boolean isJapanese() { + return japanese; } - public static String getCountryName() { - return countryName; + public static void setJapanese(boolean japanese) { + TransliterationHelper.japanese = japanese; } public static String transliterate(String text) { - switch (countryName) { - case DEFAULT: - return Junidecode.unidecode(text); - case JAPAN: - return japanese2Romaji(text); + if (japanese) { + // do not transliterate japanese for now + //return japanese2Romaji(text); + return text; + } else { + return Junidecode.unidecode(text); } - return text; } + /* private static String japanese2Romaji(String text) { if (tokenizer == null) { @@ -240,4 +222,5 @@ public class TransliterationHelper { katakanaMap.put("ピョ", "pyo"); katakanaMap.put("ー", "-"); } + */ } diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index 62873093a7..21338d2ee0 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -66,11 +66,12 @@ android { warningsAsErrors false } - packagingOptions { - exclude '/META-INF/CONTRIBUTORS.md' - exclude '/META-INF/LICENSE.md' - exclude '/META-INF/NOTICE.md' - } + // related to kuromoji + //packagingOptions { + // exclude '/META-INF/CONTRIBUTORS.md' + // exclude '/META-INF/LICENSE.md' + // exclude '/META-INF/NOTICE.md' + //} // This is from OsmAndCore_android.aar - for some reason it's not inherited aaptOptions { @@ -397,7 +398,8 @@ dependencies { implementation 'com.moparisthebest:junidecode:0.1.1' implementation 'org.immutables:gson:2.5.0' implementation 'com.vividsolutions:jts-core:1.14.0' - implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0' + // turn off for now + //implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0' implementation 'com.squareup.picasso:picasso:2.71828' // JS core implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9' diff --git a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java index 5af292158e..2575c4d6fc 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java @@ -319,13 +319,7 @@ public class MapRenderRepositories { } } } - if (containsJapanMapData) { - TransliterationHelper.setCountryName("Japan"); - } else { - TransliterationHelper.setCountryName(""); - } - - + TransliterationHelper.setJapanese(containsJapanMapData); } private void readRouteDataAsMapObjects(SearchRequest sr, BinaryMapIndexReader c, @@ -552,7 +546,7 @@ public class MapRenderRepositories { res = new ArrayList(); log.debug("Search failed " + c.getRegionNames(), e); //$NON-NLS-1$ } - if(res.size() > 0) { + if (res.size() > 0) { if(basemap) { renderedState |= 1; } else { @@ -600,12 +594,7 @@ public class MapRenderRepositories { land[0] = true; } } - if (containsJapanMapData) { - TransliterationHelper.setCountryName("Japan"); - } else { - TransliterationHelper.setCountryName(""); - } - + TransliterationHelper.setJapanese(containsJapanMapData); return mi; }