Mute atilika.kuromoji

This commit is contained in:
crimean 2019-02-21 14:16:25 +03:00
parent 24fcf4bfa8
commit 45d8204121
4 changed files with 29 additions and 54 deletions

View file

@ -89,7 +89,8 @@ dependencies {
implementation 'org.apache.commons:commons-compress:1.17' implementation 'org.apache.commons:commons-compress:1.17'
implementation 'com.moparisthebest:junidecode:0.1.1' implementation 'com.moparisthebest:junidecode:0.1.1'
implementation 'com.vividsolutions:jts-core:1.14.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 'net.sf.kxml:kxml2:2.1.8' implementation 'net.sf.kxml:kxml2:2.1.8'
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
} }

View file

@ -1,59 +1,41 @@
package net.osmand.util; 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.osmand.PlatformUtil;
import net.sf.junidecode.Junidecode; import net.sf.junidecode.Junidecode;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
public class TransliterationHelper { public class TransliterationHelper {
public final static Log LOG = PlatformUtil.getLog(TransliterationHelper.class); 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 Tokenizer tokenizer;
//private static Map<String, String> katakanaMap = new HashMap<>();
private static Map<String, String> katakanaMap = new HashMap<>();
private TransliterationHelper() { private TransliterationHelper() {
} }
public static void setCountryName(String countryName) { public static boolean isJapanese() {
if (!countryName.equals(TransliterationHelper.countryName)) { return japanese;
switch (countryName) {
case "Japan": {
TransliterationHelper.countryName = JAPAN;
break;
}
default:
TransliterationHelper.countryName = DEFAULT;
break;
}
}
} }
public static String getCountryName() { public static void setJapanese(boolean japanese) {
return countryName; TransliterationHelper.japanese = japanese;
} }
public static String transliterate(String text) { public static String transliterate(String text) {
switch (countryName) { if (japanese) {
case DEFAULT: // do not transliterate japanese for now
return Junidecode.unidecode(text); //return japanese2Romaji(text);
case JAPAN:
return japanese2Romaji(text);
}
return text; return text;
} else {
return Junidecode.unidecode(text);
}
} }
/*
private static String japanese2Romaji(String text) { private static String japanese2Romaji(String text) {
if (tokenizer == null) { if (tokenizer == null) {
@ -240,4 +222,5 @@ public class TransliterationHelper {
katakanaMap.put("ピョ", "pyo"); katakanaMap.put("ピョ", "pyo");
katakanaMap.put("", "-"); katakanaMap.put("", "-");
} }
*/
} }

View file

@ -66,11 +66,12 @@ android {
warningsAsErrors false warningsAsErrors false
} }
packagingOptions { // related to kuromoji
exclude '/META-INF/CONTRIBUTORS.md' //packagingOptions {
exclude '/META-INF/LICENSE.md' // exclude '/META-INF/CONTRIBUTORS.md'
exclude '/META-INF/NOTICE.md' // exclude '/META-INF/LICENSE.md'
} // exclude '/META-INF/NOTICE.md'
//}
// This is from OsmAndCore_android.aar - for some reason it's not inherited // This is from OsmAndCore_android.aar - for some reason it's not inherited
aaptOptions { aaptOptions {
@ -397,7 +398,8 @@ dependencies {
implementation 'com.moparisthebest:junidecode:0.1.1' implementation 'com.moparisthebest:junidecode:0.1.1'
implementation 'org.immutables:gson:2.5.0' implementation 'org.immutables:gson:2.5.0'
implementation 'com.vividsolutions:jts-core:1.14.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' implementation 'com.squareup.picasso:picasso:2.71828'
// JS core // JS core
implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9' implementation group: 'org.mozilla', name: 'rhino', version: '1.7.9'

View file

@ -319,13 +319,7 @@ public class MapRenderRepositories {
} }
} }
} }
if (containsJapanMapData) { TransliterationHelper.setJapanese(containsJapanMapData);
TransliterationHelper.setCountryName("Japan");
} else {
TransliterationHelper.setCountryName("");
}
} }
private void readRouteDataAsMapObjects(SearchRequest<BinaryMapDataObject> sr, BinaryMapIndexReader c, private void readRouteDataAsMapObjects(SearchRequest<BinaryMapDataObject> sr, BinaryMapIndexReader c,
@ -600,12 +594,7 @@ public class MapRenderRepositories {
land[0] = true; land[0] = true;
} }
} }
if (containsJapanMapData) { TransliterationHelper.setJapanese(containsJapanMapData);
TransliterationHelper.setCountryName("Japan");
} else {
TransliterationHelper.setCountryName("");
}
return mi; return mi;
} }