am d58a0766: Merge "Rename jni method for n-gram supporting."

* commit 'd58a07666e9b38086c6486f95ac2d8e8e8eeb955':
  Rename jni method for n-gram supporting.
This commit is contained in:
Keisuke Kuroyanagi 2014-06-26 06:11:12 +00:00 committed by Android Git Automerger
commit 95b5b1d1d6
4 changed files with 28 additions and 28 deletions

View file

@ -174,7 +174,7 @@ public final class BinaryDictionary extends Dictionary {
private static native int getFormatVersionNative(long dict);
private static native int getProbabilityNative(long dict, int[] word);
private static native int getMaxProbabilityOfExactMatchesNative(long dict, int[] word);
private static native int getBigramProbabilityNative(long dict, int[] word0,
private static native int getNgramProbabilityNative(long dict, int[] word0,
boolean isBeginningOfSentence, int[] word1);
private static native void getWordPropertyNative(long dict, int[] word,
boolean isBeginningOfSentence, int[] outCodePoints, boolean[] outFlags,
@ -190,13 +190,13 @@ public final class BinaryDictionary extends Dictionary {
int[] outputSuggestionCount, int[] outputCodePoints, int[] outputScores,
int[] outputIndices, int[] outputTypes, int[] outputAutoCommitFirstWordConfidence,
float[] inOutLanguageWeight);
private static native boolean addUnigramWordNative(long dict, int[] word, int probability,
private static native boolean addUnigramEntryNative(long dict, int[] word, int probability,
int[] shortcutTarget, int shortcutProbability, boolean isBeginningOfSentence,
boolean isNotAWord, boolean isBlacklisted, int timestamp);
private static native boolean removeUnigramWordNative(long dict, int[] word);
private static native boolean addBigramWordsNative(long dict, int[] word0,
private static native boolean removeUnigramEntryNative(long dict, int[] word);
private static native boolean addNgramEntryNative(long dict, int[] word0,
boolean isBeginningOfSentence, int[] word1, int probability, int timestamp);
private static native boolean removeBigramWordsNative(long dict, int[] word0,
private static native boolean removeNgramEntryNative(long dict, int[] word0,
boolean isBeginningOfSentence, int[] word1);
private static native int addMultipleDictionaryEntriesNative(long dict,
LanguageModelParam[] languageModelParams, int startIndex);
@ -359,7 +359,7 @@ public final class BinaryDictionary extends Dictionary {
new boolean[Constants.MAX_PREV_WORD_COUNT_FOR_N_GRAM];
prevWordsInfo.outputToArray(prevWordCodePointArrays, isBeginningOfSentenceArray);
final int[] wordCodePoints = StringUtils.toCodePointArray(word);
return getBigramProbabilityNative(mNativeDict, prevWordCodePointArrays[0],
return getNgramProbabilityNative(mNativeDict, prevWordCodePointArrays[0],
isBeginningOfSentenceArray[0], wordCodePoints);
}
@ -424,7 +424,7 @@ public final class BinaryDictionary extends Dictionary {
final int[] codePoints = StringUtils.toCodePointArray(word);
final int[] shortcutTargetCodePoints = (shortcutTarget != null) ?
StringUtils.toCodePointArray(shortcutTarget) : null;
if (!addUnigramWordNative(mNativeDict, codePoints, probability, shortcutTargetCodePoints,
if (!addUnigramEntryNative(mNativeDict, codePoints, probability, shortcutTargetCodePoints,
shortcutProbability, isBeginningOfSentence, isNotAWord, isBlacklisted, timestamp)) {
return false;
}
@ -438,7 +438,7 @@ public final class BinaryDictionary extends Dictionary {
return false;
}
final int[] codePoints = StringUtils.toCodePointArray(word);
if (!removeUnigramWordNative(mNativeDict, codePoints)) {
if (!removeUnigramEntryNative(mNativeDict, codePoints)) {
return false;
}
mHasUpdated = true;
@ -456,7 +456,7 @@ public final class BinaryDictionary extends Dictionary {
new boolean[Constants.MAX_PREV_WORD_COUNT_FOR_N_GRAM];
prevWordsInfo.outputToArray(prevWordCodePointArrays, isBeginningOfSentenceArray);
final int[] wordCodePoints = StringUtils.toCodePointArray(word);
if (!addBigramWordsNative(mNativeDict, prevWordCodePointArrays[0],
if (!addNgramEntryNative(mNativeDict, prevWordCodePointArrays[0],
isBeginningOfSentenceArray[0], wordCodePoints, probability, timestamp)) {
return false;
}
@ -474,7 +474,7 @@ public final class BinaryDictionary extends Dictionary {
new boolean[Constants.MAX_PREV_WORD_COUNT_FOR_N_GRAM];
prevWordsInfo.outputToArray(prevWordCodePointArrays, isBeginningOfSentenceArray);
final int[] wordCodePoints = StringUtils.toCodePointArray(word);
if (!removeBigramWordsNative(mNativeDict, prevWordCodePointArrays[0],
if (!removeNgramEntryNative(mNativeDict, prevWordCodePointArrays[0],
isBeginningOfSentenceArray[0], wordCodePoints)) {
return false;
}

View file

@ -283,7 +283,7 @@ static jint latinime_BinaryDictionary_getMaxProbabilityOfExactMatches(
return dictionary->getMaxProbabilityOfExactMatches(codePoints, wordLength);
}
static jint latinime_BinaryDictionary_getBigramProbability(JNIEnv *env, jclass clazz,
static jint latinime_BinaryDictionary_getNgramProbability(JNIEnv *env, jclass clazz,
jlong dict, jintArray word0, jboolean isBeginningOfSentence, jintArray word1) {
Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict);
if (!dictionary) return JNI_FALSE;
@ -294,7 +294,7 @@ static jint latinime_BinaryDictionary_getBigramProbability(JNIEnv *env, jclass c
env->GetIntArrayRegion(word0, 0, word0Length, word0CodePoints);
env->GetIntArrayRegion(word1, 0, word1Length, word1CodePoints);
const PrevWordsInfo prevWordsInfo(word0CodePoints, word0Length, isBeginningOfSentence);
return dictionary->getBigramProbability(&prevWordsInfo, word1CodePoints, word1Length);
return dictionary->getNgramProbability(&prevWordsInfo, word1CodePoints, word1Length);
}
// Method to iterate all words in the dictionary for makedict.
@ -355,7 +355,7 @@ static void latinime_BinaryDictionary_getWordProperty(JNIEnv *env, jclass clazz,
outShortcutProbabilities);
}
static bool latinime_BinaryDictionary_addUnigramWord(JNIEnv *env, jclass clazz, jlong dict,
static bool latinime_BinaryDictionary_addUnigramEntry(JNIEnv *env, jclass clazz, jlong dict,
jintArray word, jint probability, jintArray shortcutTarget, jint shortcutProbability,
jboolean isBeginningOfSentence, jboolean isNotAWord, jboolean isBlacklisted,
jint timestamp) {
@ -378,7 +378,7 @@ static bool latinime_BinaryDictionary_addUnigramWord(JNIEnv *env, jclass clazz,
return dictionary->addUnigramEntry(codePoints, codePointCount, &unigramProperty);
}
static bool latinime_BinaryDictionary_removeUnigramWord(JNIEnv *env, jclass clazz, jlong dict,
static bool latinime_BinaryDictionary_removeUnigramEntry(JNIEnv *env, jclass clazz, jlong dict,
jintArray word) {
Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict);
if (!dictionary) {
@ -390,7 +390,7 @@ static bool latinime_BinaryDictionary_removeUnigramWord(JNIEnv *env, jclass claz
return dictionary->removeUnigramEntry(codePoints, codePointCount);
}
static bool latinime_BinaryDictionary_addBigramWords(JNIEnv *env, jclass clazz, jlong dict,
static bool latinime_BinaryDictionary_addNgramEntry(JNIEnv *env, jclass clazz, jlong dict,
jintArray word0, jboolean isBeginningOfSentence, jintArray word1, jint probability,
jint timestamp) {
Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict);
@ -412,7 +412,7 @@ static bool latinime_BinaryDictionary_addBigramWords(JNIEnv *env, jclass clazz,
return dictionary->addNgramEntry(&prevWordsInfo, &bigramProperty);
}
static bool latinime_BinaryDictionary_removeBigramWords(JNIEnv *env, jclass clazz, jlong dict,
static bool latinime_BinaryDictionary_removeNgramEntry(JNIEnv *env, jclass clazz, jlong dict,
jintArray word0, jboolean isBeginningOfSentence, jintArray word1) {
Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict);
if (!dictionary) {
@ -686,9 +686,9 @@ static const JNINativeMethod sMethods[] = {
reinterpret_cast<void *>(latinime_BinaryDictionary_getMaxProbabilityOfExactMatches)
},
{
const_cast<char *>("getBigramProbabilityNative"),
const_cast<char *>("getNgramProbabilityNative"),
const_cast<char *>("(J[IZ[I)I"),
reinterpret_cast<void *>(latinime_BinaryDictionary_getBigramProbability)
reinterpret_cast<void *>(latinime_BinaryDictionary_getNgramProbability)
},
{
const_cast<char *>("getWordPropertyNative"),
@ -702,24 +702,24 @@ static const JNINativeMethod sMethods[] = {
reinterpret_cast<void *>(latinime_BinaryDictionary_getNextWord)
},
{
const_cast<char *>("addUnigramWordNative"),
const_cast<char *>("addUnigramEntryNative"),
const_cast<char *>("(J[II[IIZZZI)Z"),
reinterpret_cast<void *>(latinime_BinaryDictionary_addUnigramWord)
reinterpret_cast<void *>(latinime_BinaryDictionary_addUnigramEntry)
},
{
const_cast<char *>("removeUnigramWordNative"),
const_cast<char *>("removeUnigramEntryNative"),
const_cast<char *>("(J[I)Z"),
reinterpret_cast<void *>(latinime_BinaryDictionary_removeUnigramWord)
reinterpret_cast<void *>(latinime_BinaryDictionary_removeUnigramEntry)
},
{
const_cast<char *>("addBigramWordsNative"),
const_cast<char *>("addNgramEntryNative"),
const_cast<char *>("(J[IZ[III)Z"),
reinterpret_cast<void *>(latinime_BinaryDictionary_addBigramWords)
reinterpret_cast<void *>(latinime_BinaryDictionary_addNgramEntry)
},
{
const_cast<char *>("removeBigramWordsNative"),
const_cast<char *>("removeNgramEntryNative"),
const_cast<char *>("(J[IZ[I)Z"),
reinterpret_cast<void *>(latinime_BinaryDictionary_removeBigramWords)
reinterpret_cast<void *>(latinime_BinaryDictionary_removeNgramEntry)
},
{
const_cast<char *>("addMultipleDictionaryEntriesNative"),

View file

@ -81,7 +81,7 @@ int Dictionary::getMaxProbabilityOfExactMatches(const int *word, int length) con
mDictionaryStructureWithBufferPolicy.get(), word, length);
}
int Dictionary::getBigramProbability(const PrevWordsInfo *const prevWordsInfo, const int *word,
int Dictionary::getNgramProbability(const PrevWordsInfo *const prevWordsInfo, const int *word,
int length) const {
TimeKeeper::setCurrentTime();
return mBigramDictionary.getBigramProbability(prevWordsInfo, word, length);

View file

@ -75,7 +75,7 @@ class Dictionary {
int getMaxProbabilityOfExactMatches(const int *word, int length) const;
int getBigramProbability(const PrevWordsInfo *const prevWordsInfo,
int getNgramProbability(const PrevWordsInfo *const prevWordsInfo,
const int *word, int length) const;
bool addUnigramEntry(const int *const codePoints, const int codePointCount,