am 95711bfc: Add Decoder specific dictionary suffix to resource lookup

* commit '95711bfcee07d848883316cf07439408f5b332a1':
  Add Decoder specific dictionary suffix to resource lookup
main
Mohammadinamul Sheik 2015-02-13 07:19:55 +00:00 committed by Android Git Automerger
commit baefd1c87e
2 changed files with 7 additions and 3 deletions

View File

@ -27,4 +27,7 @@ public class DecoderSpecificConstants {
// (MAX_PREV_WORD_COUNT_FOR_N_GRAM + 1)-gram is supported in Java side. Needs to modify // (MAX_PREV_WORD_COUNT_FOR_N_GRAM + 1)-gram is supported in Java side. Needs to modify
// MAX_PREV_WORD_COUNT_FOR_N_GRAM in native/jni/src/defines.h for suggestions. // MAX_PREV_WORD_COUNT_FOR_N_GRAM in native/jni/src/defines.h for suggestions.
public static final int MAX_PREV_WORD_COUNT_FOR_N_GRAM = 3; public static final int MAX_PREV_WORD_COUNT_FOR_N_GRAM = 3;
public static final String DECODER_DICT_SUFFIX = "";
} }

View File

@ -51,6 +51,7 @@ public class DictionaryInfoUtils {
private static final String RESOURCE_PACKAGE_NAME = R.class.getPackage().getName(); private static final String RESOURCE_PACKAGE_NAME = R.class.getPackage().getName();
private static final String DEFAULT_MAIN_DICT = "main"; private static final String DEFAULT_MAIN_DICT = "main";
private static final String MAIN_DICT_PREFIX = "main_"; private static final String MAIN_DICT_PREFIX = "main_";
private static final String DECODER_DICT_SUFFIX = DecoderSpecificConstants.DECODER_DICT_SUFFIX;
// 6 digits - unicode is limited to 21 bits // 6 digits - unicode is limited to 21 bits
private static final int MAX_HEX_DIGITS_FOR_CODEPOINT = 6; private static final int MAX_HEX_DIGITS_FOR_CODEPOINT = 6;
@ -267,8 +268,8 @@ public class DictionaryInfoUtils {
int resId; int resId;
// Try to find main_language_country dictionary. // Try to find main_language_country dictionary.
if (!locale.getCountry().isEmpty()) { if (!locale.getCountry().isEmpty()) {
final String dictLanguageCountry = final String dictLanguageCountry = MAIN_DICT_PREFIX
MAIN_DICT_PREFIX + locale.toString().toLowerCase(Locale.ROOT); + locale.toString().toLowerCase(Locale.ROOT) + DECODER_DICT_SUFFIX;
if ((resId = res.getIdentifier( if ((resId = res.getIdentifier(
dictLanguageCountry, "raw", RESOURCE_PACKAGE_NAME)) != 0) { dictLanguageCountry, "raw", RESOURCE_PACKAGE_NAME)) != 0) {
return resId; return resId;
@ -276,7 +277,7 @@ public class DictionaryInfoUtils {
} }
// Try to find main_language dictionary. // Try to find main_language dictionary.
final String dictLanguage = MAIN_DICT_PREFIX + locale.getLanguage(); final String dictLanguage = MAIN_DICT_PREFIX + locale.getLanguage() + DECODER_DICT_SUFFIX;
if ((resId = res.getIdentifier(dictLanguage, "raw", RESOURCE_PACKAGE_NAME)) != 0) { if ((resId = res.getIdentifier(dictLanguage, "raw", RESOURCE_PACKAGE_NAME)) != 0) {
return resId; return resId;
} }