parent
f25cc4405e
commit
fe9ec6bc7d
|
@ -101,7 +101,7 @@ public final class BinaryDictionary extends Dictionary {
|
|||
}
|
||||
|
||||
private native long openNative(String sourceDir, long dictOffset, long dictSize,
|
||||
int fullWordMultiplier, int maxWordLength, int maxWords, int maxPredictions);
|
||||
int maxWordLength, int maxWords, int maxPredictions);
|
||||
private native void closeNative(long dict);
|
||||
private native int getFrequencyNative(long dict, int[] word);
|
||||
private native boolean isValidBigramNative(long dict, int[] word1, int[] word2);
|
||||
|
@ -116,8 +116,8 @@ public final class BinaryDictionary extends Dictionary {
|
|||
// TODO: Move native dict into session
|
||||
private final void loadDictionary(final String path, final long startOffset,
|
||||
final long length) {
|
||||
mNativeDict = openNative(path, startOffset, length, FULL_WORD_SCORE_MULTIPLIER,
|
||||
MAX_WORD_LENGTH, MAX_WORDS, MAX_PREDICTIONS);
|
||||
mNativeDict = openNative(path, startOffset, length, MAX_WORD_LENGTH, MAX_WORDS,
|
||||
MAX_PREDICTIONS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,11 +26,6 @@ import java.util.ArrayList;
|
|||
* strokes.
|
||||
*/
|
||||
public abstract class Dictionary {
|
||||
/**
|
||||
* The weight to give to a word if it's length is the same as the number of typed characters.
|
||||
*/
|
||||
protected static final int FULL_WORD_SCORE_MULTIPLIER = 2;
|
||||
|
||||
public static final int NOT_A_PROBABILITY = -1;
|
||||
|
||||
public static final String TYPE_USER_TYPED = "user_typed";
|
||||
|
|
|
@ -31,6 +31,10 @@ import java.util.LinkedList;
|
|||
* be searched for suggestions and valid words.
|
||||
*/
|
||||
public class ExpandableDictionary extends Dictionary {
|
||||
/**
|
||||
* The weight to give to a word if it's length is the same as the number of typed characters.
|
||||
*/
|
||||
private static final int FULL_WORD_SCORE_MULTIPLIER = 2;
|
||||
|
||||
// Bigram frequency is a fixed point number with 1 meaning 1.2 and 255 meaning 1.8.
|
||||
protected static final int BIGRAM_MAX_FREQUENCY = 255;
|
||||
|
|
|
@ -43,9 +43,8 @@ class ProximityInfo;
|
|||
|
||||
static void releaseDictBuf(const void *dictBuf, const size_t length, const int fd);
|
||||
|
||||
static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
|
||||
jstring sourceDir, jlong dictOffset, jlong dictSize, jint fullWordMultiplier,
|
||||
jint maxWordLength, jint maxWords, jint maxPredictions) {
|
||||
static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object, jstring sourceDir,
|
||||
jlong dictOffset, jlong dictSize, jint maxWordLength, jint maxWords, jint maxPredictions) {
|
||||
PROF_OPEN;
|
||||
PROF_START(66);
|
||||
const jsize sourceDirUtf8Length = env->GetStringUTFLength(sourceDir);
|
||||
|
@ -119,8 +118,8 @@ static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
|
|||
releaseDictBuf(dictBuf, 0, 0);
|
||||
#endif // USE_MMAP_FOR_DICTIONARY
|
||||
} else {
|
||||
dictionary = new Dictionary(dictBuf, static_cast<int>(dictSize), fd, adjust,
|
||||
fullWordMultiplier, maxWordLength, maxWords, maxPredictions);
|
||||
dictionary = new Dictionary(dictBuf, static_cast<int>(dictSize), fd, adjust, maxWordLength,
|
||||
maxWords, maxPredictions);
|
||||
}
|
||||
PROF_END(66);
|
||||
PROF_CLOSE;
|
||||
|
@ -272,7 +271,7 @@ static void releaseDictBuf(const void *dictBuf, const size_t length, const int f
|
|||
}
|
||||
|
||||
static JNINativeMethod sMethods[] = {
|
||||
{"openNative", "(Ljava/lang/String;JJIIII)J",
|
||||
{"openNative", "(Ljava/lang/String;JJIII)J",
|
||||
reinterpret_cast<void *>(latinime_BinaryDictionary_open)},
|
||||
{"closeNative", "(J)V", reinterpret_cast<void *>(latinime_BinaryDictionary_close)},
|
||||
{"getSuggestionsNative", "(JJJ[I[I[I[I[IIIZ[IZ[I[I[I[I)I",
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
namespace latinime {
|
||||
|
||||
// TODO: Change the type of all keyCodes to uint32_t
|
||||
Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
|
||||
int fullWordMultiplier, int maxWordLength, int maxWords, int maxPredictions)
|
||||
Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int maxWordLength,
|
||||
int maxWords, int maxPredictions)
|
||||
: mDict(static_cast<unsigned char *>(dict)),
|
||||
mOffsetDict((static_cast<unsigned char *>(dict)) + BinaryFormat::getHeaderSize(mDict)),
|
||||
mDictSize(dictSize), mMmapFd(mmapFd), mDictBufAdjust(dictBufAdjust),
|
||||
mUnigramDictionary(new UnigramDictionary(mOffsetDict, fullWordMultiplier, maxWordLength,
|
||||
maxWords, BinaryFormat::getFlags(mDict))),
|
||||
mUnigramDictionary(new UnigramDictionary(mOffsetDict, maxWordLength, maxWords,
|
||||
BinaryFormat::getFlags(mDict))),
|
||||
mBigramDictionary(new BigramDictionary(mOffsetDict, maxWordLength, maxPredictions)),
|
||||
mGestureDecoder(new GestureDecoderWrapper(maxWordLength, maxWords)) {
|
||||
if (DEBUG_DICT) {
|
||||
|
|
|
@ -41,8 +41,8 @@ class Dictionary {
|
|||
const static int KIND_SHORTCUT = 7; // A shortcut
|
||||
const static int KIND_PREDICTION = 8; // A prediction (== a suggestion with no input)
|
||||
|
||||
Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int fullWordMultiplier,
|
||||
int maxWordLength, int maxWords, int maxPredictions);
|
||||
Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int maxWordLength,
|
||||
int maxWords, int maxPredictions);
|
||||
|
||||
int getSuggestions(ProximityInfo *proximityInfo, void *traverseSession, int *xcoordinates,
|
||||
int *ycoordinates, int *times, int *pointerIds, int *codes, int codesSize,
|
||||
|
|
|
@ -41,10 +41,9 @@ const UnigramDictionary::digraph_t UnigramDictionary::FRENCH_LIGATURES_DIGRAPHS[
|
|||
{ 'o', 'e', 0x0153 } }; // U+0153 : LATIN SMALL LIGATURE OE
|
||||
|
||||
// TODO: check the header
|
||||
UnigramDictionary::UnigramDictionary(const uint8_t *const streamStart, int fullWordMultiplier,
|
||||
int maxWordLength, int maxWords, const unsigned int flags)
|
||||
UnigramDictionary::UnigramDictionary(const uint8_t *const streamStart, int maxWordLength,
|
||||
int maxWords, const unsigned int flags)
|
||||
: DICT_ROOT(streamStart), MAX_WORD_LENGTH(maxWordLength), MAX_WORDS(maxWords),
|
||||
FULL_WORD_MULTIPLIER(fullWordMultiplier), // TODO : remove this variable.
|
||||
ROOT_POS(0), MAX_DIGRAPH_SEARCH_DEPTH(DEFAULT_MAX_DIGRAPH_SEARCH_DEPTH), FLAGS(flags) {
|
||||
if (DEBUG_DICT) {
|
||||
AKLOGI("UnigramDictionary - constructor");
|
||||
|
|
|
@ -39,8 +39,8 @@ class UnigramDictionary {
|
|||
static const int FLAG_MULTIPLE_SUGGEST_ABORT = 0;
|
||||
static const int FLAG_MULTIPLE_SUGGEST_SKIP = 1;
|
||||
static const int FLAG_MULTIPLE_SUGGEST_CONTINUE = 2;
|
||||
UnigramDictionary(const uint8_t *const streamStart, int fullWordMultiplier, int maxWordLength,
|
||||
int maxWords, const unsigned int flags);
|
||||
UnigramDictionary(const uint8_t *const streamStart, int maxWordLength, int maxWords,
|
||||
const unsigned int flags);
|
||||
int getFrequency(const int *const inWord, const int length) const;
|
||||
int getBigramPosition(int pos, int *word, int offset, int length) const;
|
||||
int getSuggestions(ProximityInfo *proximityInfo, const int *xcoordinates,
|
||||
|
@ -114,7 +114,6 @@ class UnigramDictionary {
|
|||
const uint8_t *const DICT_ROOT;
|
||||
const int MAX_WORD_LENGTH;
|
||||
const int MAX_WORDS;
|
||||
const int FULL_WORD_MULTIPLIER;
|
||||
const int ROOT_POS;
|
||||
const int MAX_DIGRAPH_SEARCH_DEPTH;
|
||||
const int FLAGS;
|
||||
|
|
Loading…
Reference in New Issue