diff options
author | 2010-04-28 18:12:58 -0700 | |
---|---|---|
committer | 2010-05-07 13:40:20 -0700 | |
commit | e4e1130d003a75e3b5cbea1678755d2b71d7cb1d (patch) | |
tree | 7a55da5d4c9923c0392438237561026fe347f765 /java/src/com/android/inputmethod/latin/BinaryDictionary.java | |
parent | f53d0da540d4aca9c0b78938094e13a828ab1bd6 (diff) | |
download | latinime-e4e1130d003a75e3b5cbea1678755d2b71d7cb1d.tar.gz latinime-e4e1130d003a75e3b5cbea1678755d2b71d7cb1d.tar.xz latinime-e4e1130d003a75e3b5cbea1678755d2b71d7cb1d.zip |
Tests and some new constructors to help in testing.
Added tests for the dictionary lookup and correction logic on the primary dictionary.
This exercises part of the Suggest class and the native dictionary lookup code.
Diffstat (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionary.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionary.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 4901b210b..6473f4558 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -68,6 +68,26 @@ public class BinaryDictionary extends Dictionary { } } + /** + * Create a dictionary from a byte buffer. This is used for testing. + * @param context application context for reading resources + * @param resId the resource containing the raw binary dictionary + */ + public BinaryDictionary(Context context, ByteBuffer byteBuffer) { + if (byteBuffer != null) { + if (byteBuffer.isDirect()) { + mNativeDictDirectBuffer = byteBuffer; + } else { + mNativeDictDirectBuffer = ByteBuffer.allocateDirect(byteBuffer.capacity()); + byteBuffer.rewind(); + mNativeDictDirectBuffer.put(byteBuffer); + } + mDictLength = byteBuffer.capacity(); + mNativeDict = openNative(mNativeDictDirectBuffer, + TYPED_LETTER_MULTIPLIER, FULL_WORD_FREQ_MULTIPLIER); + } + } + private native int openNative(ByteBuffer bb, int typedLetterMultiplier, int fullWordMultiplier); private native void closeNative(int dict); private native boolean isValidWordNative(int nativeData, char[] word, int wordLength); |