diff options
author | 2012-01-12 03:00:54 -0800 | |
---|---|---|
committer | 2012-01-12 03:00:54 -0800 | |
commit | 280cc53e1c4702e724915a78d00e00e552f7003f (patch) | |
tree | f6236e3c6040f91d381738db515d1a1bb0df422f /java/src/com/android/inputmethod/latin/BinaryDictionary.java | |
parent | ae2a4eedd22d73ecae680d022972dcaacb7c6702 (diff) | |
parent | 21814c56f0859a2d83d1ecc29f4a74210c4497a1 (diff) | |
download | latinime-280cc53e1c4702e724915a78d00e00e552f7003f.tar.gz latinime-280cc53e1c4702e724915a78d00e00e552f7003f.tar.xz latinime-280cc53e1c4702e724915a78d00e00e552f7003f.zip |
am 21814c56: Merge "Move auto correction thresthold to the native code"
* commit '21814c56f0859a2d83d1ecc29f4a74210c4497a1':
Move auto correction thresthold to the native code
Diffstat (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionary.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionary.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index f0e56d346..3692ac179 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -118,6 +118,10 @@ public class BinaryDictionary extends Dictionary { private native int getBigramsNative(long dict, char[] prevWord, int prevWordLength, int[] inputCodes, int inputCodesLength, char[] outputChars, int[] scores, int maxWordLength, int maxBigrams, int maxAlternatives); + private static native double calcNormalizedScoreNative( + char[] before, int beforeLength, char[] after, int afterLength, int score); + private static native int editDistanceNative( + char[] before, int beforeLength, char[] after, int afterLength); private final void loadDictionary(String path, long startOffset, long length) { mNativeDict = openNative(path, startOffset, length, @@ -211,6 +215,16 @@ public class BinaryDictionary extends Dictionary { mFlags, outputChars, scores); } + public static double calcNormalizedScore(String before, String after, int score) { + return calcNormalizedScoreNative(before.toCharArray(), before.length(), + after.toCharArray(), after.length(), score); + } + + public static int editDistance(String before, String after) { + return editDistanceNative( + before.toCharArray(), before.length(), after.toCharArray(), after.length()); + } + @Override public boolean isValidWord(CharSequence word) { if (word == null) return false; |