aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/SuggestHelper.java
diff options
context:
space:
mode:
authorKen Wakasa <kwakasa@google.com>2011-01-07 15:01:51 +0900
committerKen Wakasa <kwakasa@google.com>2011-01-07 19:51:45 +0900
commite90b333017c68e888a5e3d351f07ea29036457d0 (patch)
treedd51657376f1c571df581b7016be891d09246be5 /tests/src/com/android/inputmethod/latin/SuggestHelper.java
parentf16028b92e15c0fdf3fdc364d7888cf024723b00 (diff)
downloadlatinime-e90b333017c68e888a5e3d351f07ea29036457d0.tar.gz
latinime-e90b333017c68e888a5e3d351f07ea29036457d0.tar.xz
latinime-e90b333017c68e888a5e3d351f07ea29036457d0.zip
Load main dic in native
Follow up to Id57dce51 bug: 3219819 Change-Id: I00e11ef21d0252ffa88c12dffb9c55b0f2e19a66
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/SuggestHelper.java')
-rw-r--r--tests/src/com/android/inputmethod/latin/SuggestHelper.java40
1 files changed, 3 insertions, 37 deletions
diff --git a/tests/src/com/android/inputmethod/latin/SuggestHelper.java b/tests/src/com/android/inputmethod/latin/SuggestHelper.java
index 7254520d5..de898c3ea 100644
--- a/tests/src/com/android/inputmethod/latin/SuggestHelper.java
+++ b/tests/src/com/android/inputmethod/latin/SuggestHelper.java
@@ -38,49 +38,15 @@ public class SuggestHelper {
private final String TAG;
/** Uses main dictionary only **/
- public SuggestHelper(String tag, Context context, int[] resId) {
+ public SuggestHelper(String tag, Context context, int resId) {
TAG = tag;
- InputStream[] is = null;
- try {
- // merging separated dictionary into one if dictionary is separated
- int total = 0;
- is = new InputStream[resId.length];
- for (int i = 0; i < resId.length; i++) {
- is[i] = context.getResources().openRawResource(resId[i]);
- total += is[i].available();
- }
-
- ByteBuffer byteBuffer =
- ByteBuffer.allocateDirect(total).order(ByteOrder.nativeOrder());
- int got = 0;
- for (int i = 0; i < resId.length; i++) {
- got += Channels.newChannel(is[i]).read(byteBuffer);
- }
- if (got != total) {
- Log.w(TAG, "Read " + got + " bytes, expected " + total);
- } else {
- mSuggest = new Suggest(context, byteBuffer);
- Log.i(TAG, "Created mSuggest " + total + " bytes");
- }
- } catch (IOException e) {
- Log.w(TAG, "No available memory for binary dictionary");
- } finally {
- try {
- if (is != null) {
- for (int i = 0; i < is.length; i++) {
- is[i].close();
- }
- }
- } catch (IOException e) {
- Log.w(TAG, "Failed to close input stream");
- }
- }
+ mSuggest = new Suggest(context, resId);
mSuggest.setAutoTextEnabled(false);
mSuggest.setCorrectionMode(Suggest.CORRECTION_FULL_BIGRAM);
}
/** Uses both main dictionary and user-bigram dictionary **/
- public SuggestHelper(String tag, Context context, int[] resId, int userBigramMax,
+ public SuggestHelper(String tag, Context context, int resId, int userBigramMax,
int userBigramDelete) {
this(tag, context, resId);
mUserBigram = new UserBigramDictionary(context, null, Locale.US.toString(),