Good bye the proximity logic in Java code
Bug: 4343280 Change-Id: I82f7d08703647a3492ce6e2d3b741146df58927emain
parent
67094f5bde
commit
6ba8de2a60
|
@ -40,14 +40,13 @@ public class BinaryDictionary extends Dictionary {
|
||||||
public static final int MAX_WORDS = 18;
|
public static final int MAX_WORDS = 18;
|
||||||
|
|
||||||
private static final String TAG = "BinaryDictionary";
|
private static final String TAG = "BinaryDictionary";
|
||||||
private static final int MAX_PROXIMITY_CHARS_SIZE = ProximityInfo.MAX_PROXIMITY_CHARS_SIZE;
|
|
||||||
private static final int MAX_BIGRAMS = 60;
|
private static final int MAX_BIGRAMS = 60;
|
||||||
|
|
||||||
private static final int TYPED_LETTER_MULTIPLIER = 2;
|
private static final int TYPED_LETTER_MULTIPLIER = 2;
|
||||||
|
|
||||||
private int mDicTypeId;
|
private int mDicTypeId;
|
||||||
private long mNativeDict;
|
private long mNativeDict;
|
||||||
private final int[] mInputCodes = new int[MAX_WORD_LENGTH * MAX_PROXIMITY_CHARS_SIZE];
|
private final int[] mInputCodes = new int[MAX_WORD_LENGTH];
|
||||||
private final char[] mOutputChars = new char[MAX_WORD_LENGTH * MAX_WORDS];
|
private final char[] mOutputChars = new char[MAX_WORD_LENGTH * MAX_WORDS];
|
||||||
private final char[] mOutputChars_bigrams = new char[MAX_WORD_LENGTH * MAX_BIGRAMS];
|
private final char[] mOutputChars_bigrams = new char[MAX_WORD_LENGTH * MAX_BIGRAMS];
|
||||||
private final int[] mScores = new int[MAX_WORDS];
|
private final int[] mScores = new int[MAX_WORDS];
|
||||||
|
@ -111,8 +110,7 @@ public class BinaryDictionary extends Dictionary {
|
||||||
}
|
}
|
||||||
|
|
||||||
private native long openNative(String sourceDir, long dictOffset, long dictSize,
|
private native long openNative(String sourceDir, long dictOffset, long dictSize,
|
||||||
int typedLetterMultiplier, int fullWordMultiplier, int maxWordLength,
|
int typedLetterMultiplier, int fullWordMultiplier, int maxWordLength, int maxWords);
|
||||||
int maxWords, int maxAlternatives);
|
|
||||||
private native void closeNative(long dict);
|
private native void closeNative(long dict);
|
||||||
private native boolean isValidWordNative(long dict, char[] word, int wordLength);
|
private native boolean isValidWordNative(long dict, char[] word, int wordLength);
|
||||||
private native int getSuggestionsNative(long dict, long proximityInfo, int[] xCoordinates,
|
private native int getSuggestionsNative(long dict, long proximityInfo, int[] xCoordinates,
|
||||||
|
@ -120,7 +118,7 @@ public class BinaryDictionary extends Dictionary {
|
||||||
int[] scores);
|
int[] scores);
|
||||||
private native int getBigramsNative(long dict, char[] prevWord, int prevWordLength,
|
private native int getBigramsNative(long dict, char[] prevWord, int prevWordLength,
|
||||||
int[] inputCodes, int inputCodesLength, char[] outputChars, int[] scores,
|
int[] inputCodes, int inputCodesLength, char[] outputChars, int[] scores,
|
||||||
int maxWordLength, int maxBigrams, int maxAlternatives);
|
int maxWordLength, int maxBigrams);
|
||||||
private static native double calcNormalizedScoreNative(
|
private static native double calcNormalizedScoreNative(
|
||||||
char[] before, int beforeLength, char[] after, int afterLength, int score);
|
char[] before, int beforeLength, char[] after, int afterLength, int score);
|
||||||
private static native int editDistanceNative(
|
private static native int editDistanceNative(
|
||||||
|
@ -128,8 +126,7 @@ public class BinaryDictionary extends Dictionary {
|
||||||
|
|
||||||
private final void loadDictionary(String path, long startOffset, long length) {
|
private final void loadDictionary(String path, long startOffset, long length) {
|
||||||
mNativeDict = openNative(path, startOffset, length,
|
mNativeDict = openNative(path, startOffset, length,
|
||||||
TYPED_LETTER_MULTIPLIER, FULL_WORD_SCORE_MULTIPLIER,
|
TYPED_LETTER_MULTIPLIER, FULL_WORD_SCORE_MULTIPLIER, MAX_WORD_LENGTH, MAX_WORDS);
|
||||||
MAX_WORD_LENGTH, MAX_WORDS, MAX_PROXIMITY_CHARS_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -148,8 +145,7 @@ public class BinaryDictionary extends Dictionary {
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = getBigramsNative(mNativeDict, chars, chars.length, mInputCodes, codesSize,
|
int count = getBigramsNative(mNativeDict, chars, chars.length, mInputCodes, codesSize,
|
||||||
mOutputChars_bigrams, mBigramScores, MAX_WORD_LENGTH, MAX_BIGRAMS,
|
mOutputChars_bigrams, mBigramScores, MAX_WORD_LENGTH, MAX_BIGRAMS);
|
||||||
MAX_PROXIMITY_CHARS_SIZE);
|
|
||||||
if (count > MAX_BIGRAMS) {
|
if (count > MAX_BIGRAMS) {
|
||||||
count = MAX_BIGRAMS;
|
count = MAX_BIGRAMS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,6 @@ public class WordComposer {
|
||||||
|
|
||||||
// TODO: remove input keyDetector
|
// TODO: remove input keyDetector
|
||||||
public void add(int primaryCode, int x, int y, KeyDetector keyDetector) {
|
public void add(int primaryCode, int x, int y, KeyDetector keyDetector) {
|
||||||
final int[] codes;
|
|
||||||
final int keyX;
|
final int keyX;
|
||||||
final int keyY;
|
final int keyY;
|
||||||
if (null == keyDetector
|
if (null == keyDetector
|
||||||
|
@ -135,16 +134,13 @@ public class WordComposer {
|
||||||
|| y == KeyboardActionListener.SUGGESTION_STRIP_COORDINATE
|
|| y == KeyboardActionListener.SUGGESTION_STRIP_COORDINATE
|
||||||
|| x == KeyboardActionListener.NOT_A_TOUCH_COORDINATE
|
|| x == KeyboardActionListener.NOT_A_TOUCH_COORDINATE
|
||||||
|| y == KeyboardActionListener.NOT_A_TOUCH_COORDINATE) {
|
|| y == KeyboardActionListener.NOT_A_TOUCH_COORDINATE) {
|
||||||
codes = new int[] { primaryCode };
|
|
||||||
keyX = x;
|
keyX = x;
|
||||||
keyY = y;
|
keyY = y;
|
||||||
} else {
|
} else {
|
||||||
// TODO: Pass an integer instead of an integer array
|
|
||||||
codes = new int[] { primaryCode };
|
|
||||||
keyX = keyDetector.getTouchX(x);
|
keyX = keyDetector.getTouchX(x);
|
||||||
keyY = keyDetector.getTouchY(y);
|
keyY = keyDetector.getTouchY(y);
|
||||||
}
|
}
|
||||||
add(primaryCode, codes, keyX, keyY);
|
add(primaryCode, keyX, keyY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,7 +148,7 @@ public class WordComposer {
|
||||||
* the array containing unicode for adjacent keys, sorted by reducing probability/proximity.
|
* the array containing unicode for adjacent keys, sorted by reducing probability/proximity.
|
||||||
* @param codes the array of unicode values
|
* @param codes the array of unicode values
|
||||||
*/
|
*/
|
||||||
private void add(int primaryCode, int[] codes, int keyX, int keyY) {
|
private void add(int primaryCode, int keyX, int keyY) {
|
||||||
final int newIndex = size();
|
final int newIndex = size();
|
||||||
mTypedWord.appendCodePoint(primaryCode);
|
mTypedWord.appendCodePoint(primaryCode);
|
||||||
refreshSize();
|
refreshSize();
|
||||||
|
@ -181,13 +177,11 @@ public class WordComposer {
|
||||||
if (key.mCode == codePoint) {
|
if (key.mCode == codePoint) {
|
||||||
final int x = key.mX + key.mWidth / 2;
|
final int x = key.mX + key.mWidth / 2;
|
||||||
final int y = key.mY + key.mHeight / 2;
|
final int y = key.mY + key.mHeight / 2;
|
||||||
// TODO: Pass an integer instead of an integer array
|
add(codePoint, x, y);
|
||||||
add(codePoint, new int[] { key.mCode }, x, y);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add(codePoint, new int[] { codePoint },
|
add(codePoint, WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
|
||||||
WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -45,8 +45,7 @@ void releaseDictBuf(void* dictBuf, const size_t length, int fd);
|
||||||
|
|
||||||
static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
|
static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
|
||||||
jstring sourceDir, jlong dictOffset, jlong dictSize,
|
jstring sourceDir, jlong dictOffset, jlong dictSize,
|
||||||
jint typedLetterMultiplier, jint fullWordMultiplier, jint maxWordLength, jint maxWords,
|
jint typedLetterMultiplier, jint fullWordMultiplier, jint maxWordLength, jint maxWords) {
|
||||||
jint maxAlternatives) {
|
|
||||||
PROF_OPEN;
|
PROF_OPEN;
|
||||||
PROF_START(66);
|
PROF_START(66);
|
||||||
const char *sourceDirChars = env->GetStringUTFChars(sourceDir, 0);
|
const char *sourceDirChars = env->GetStringUTFChars(sourceDir, 0);
|
||||||
|
@ -119,7 +118,7 @@ static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
|
||||||
#endif // USE_MMAP_FOR_DICTIONARY
|
#endif // USE_MMAP_FOR_DICTIONARY
|
||||||
} else {
|
} else {
|
||||||
dictionary = new Dictionary(dictBuf, dictSize, fd, adjust, typedLetterMultiplier,
|
dictionary = new Dictionary(dictBuf, dictSize, fd, adjust, typedLetterMultiplier,
|
||||||
fullWordMultiplier, maxWordLength, maxWords, maxAlternatives);
|
fullWordMultiplier, maxWordLength, maxWords);
|
||||||
}
|
}
|
||||||
PROF_END(66);
|
PROF_END(66);
|
||||||
PROF_CLOSE;
|
PROF_CLOSE;
|
||||||
|
@ -155,8 +154,7 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object,
|
||||||
|
|
||||||
static int latinime_BinaryDictionary_getBigrams(JNIEnv *env, jobject object, jlong dict,
|
static int latinime_BinaryDictionary_getBigrams(JNIEnv *env, jobject object, jlong dict,
|
||||||
jcharArray prevWordArray, jint prevWordLength, jintArray inputArray, jint inputArraySize,
|
jcharArray prevWordArray, jint prevWordLength, jintArray inputArray, jint inputArraySize,
|
||||||
jcharArray outputArray, jintArray frequencyArray, jint maxWordLength, jint maxBigrams,
|
jcharArray outputArray, jintArray frequencyArray, jint maxWordLength, jint maxBigrams) {
|
||||||
jint maxAlternatives) {
|
|
||||||
Dictionary *dictionary = (Dictionary*)dict;
|
Dictionary *dictionary = (Dictionary*)dict;
|
||||||
if (!dictionary) return 0;
|
if (!dictionary) return 0;
|
||||||
|
|
||||||
|
@ -166,8 +164,7 @@ static int latinime_BinaryDictionary_getBigrams(JNIEnv *env, jobject object, jlo
|
||||||
int *frequencies = env->GetIntArrayElements(frequencyArray, 0);
|
int *frequencies = env->GetIntArrayElements(frequencyArray, 0);
|
||||||
|
|
||||||
int count = dictionary->getBigrams((unsigned short*) prevWord, prevWordLength, inputCodes,
|
int count = dictionary->getBigrams((unsigned short*) prevWord, prevWordLength, inputCodes,
|
||||||
inputArraySize, (unsigned short*) outputChars, frequencies, maxWordLength, maxBigrams,
|
inputArraySize, (unsigned short*) outputChars, frequencies, maxWordLength, maxBigrams);
|
||||||
maxAlternatives);
|
|
||||||
|
|
||||||
env->ReleaseCharArrayElements(prevWordArray, prevWord, JNI_ABORT);
|
env->ReleaseCharArrayElements(prevWordArray, prevWord, JNI_ABORT);
|
||||||
env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT);
|
env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT);
|
||||||
|
@ -242,11 +239,11 @@ void releaseDictBuf(void* dictBuf, const size_t length, int fd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static JNINativeMethod sMethods[] = {
|
static JNINativeMethod sMethods[] = {
|
||||||
{"openNative", "(Ljava/lang/String;JJIIIII)J", (void*)latinime_BinaryDictionary_open},
|
{"openNative", "(Ljava/lang/String;JJIIII)J", (void*)latinime_BinaryDictionary_open},
|
||||||
{"closeNative", "(J)V", (void*)latinime_BinaryDictionary_close},
|
{"closeNative", "(J)V", (void*)latinime_BinaryDictionary_close},
|
||||||
{"getSuggestionsNative", "(JJ[I[I[III[C[I)I", (void*)latinime_BinaryDictionary_getSuggestions},
|
{"getSuggestionsNative", "(JJ[I[I[III[C[I)I", (void*)latinime_BinaryDictionary_getSuggestions},
|
||||||
{"isValidWordNative", "(J[CI)Z", (void*)latinime_BinaryDictionary_isValidWord},
|
{"isValidWordNative", "(J[CI)Z", (void*)latinime_BinaryDictionary_isValidWord},
|
||||||
{"getBigramsNative", "(J[CI[II[C[IIII)I", (void*)latinime_BinaryDictionary_getBigrams},
|
{"getBigramsNative", "(J[CI[II[C[III)I", (void*)latinime_BinaryDictionary_getBigrams},
|
||||||
{"calcNormalizedScoreNative", "([CI[CII)D",
|
{"calcNormalizedScoreNative", "([CI[CII)D",
|
||||||
(void*)latinime_BinaryDictionary_calcNormalizedScore},
|
(void*)latinime_BinaryDictionary_calcNormalizedScore},
|
||||||
{"editDistanceNative", "([CI[CI)I", (void*)latinime_BinaryDictionary_editDistance}
|
{"editDistanceNative", "([CI[CI)I", (void*)latinime_BinaryDictionary_editDistance}
|
||||||
|
|
|
@ -26,10 +26,10 @@
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
BigramDictionary::BigramDictionary(const unsigned char *dict, int maxWordLength,
|
BigramDictionary::BigramDictionary(const unsigned char *dict, int maxWordLength,
|
||||||
int maxAlternatives, const bool isLatestDictVersion, const bool hasBigram,
|
const bool isLatestDictVersion, const bool hasBigram,
|
||||||
Dictionary *parentDictionary)
|
Dictionary *parentDictionary)
|
||||||
: DICT(dict), MAX_WORD_LENGTH(maxWordLength),
|
: DICT(dict), MAX_WORD_LENGTH(maxWordLength),
|
||||||
MAX_ALTERNATIVES(maxAlternatives), IS_LATEST_DICT_VERSION(isLatestDictVersion),
|
IS_LATEST_DICT_VERSION(isLatestDictVersion),
|
||||||
HAS_BIGRAM(hasBigram), mParentDictionary(parentDictionary) {
|
HAS_BIGRAM(hasBigram), mParentDictionary(parentDictionary) {
|
||||||
if (DEBUG_DICT) {
|
if (DEBUG_DICT) {
|
||||||
AKLOGI("BigramDictionary - constructor");
|
AKLOGI("BigramDictionary - constructor");
|
||||||
|
@ -92,7 +92,6 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
|
||||||
* bigramFreq: an array to output frequencies.
|
* bigramFreq: an array to output frequencies.
|
||||||
* maxWordLength: the maximum size of a word.
|
* maxWordLength: the maximum size of a word.
|
||||||
* maxBigrams: the maximum number of bigrams fitting in the bigramChars array.
|
* maxBigrams: the maximum number of bigrams fitting in the bigramChars array.
|
||||||
* maxAlteratives: unused.
|
|
||||||
* This method returns the number of bigrams this word has, for backward compatibility.
|
* This method returns the number of bigrams this word has, for backward compatibility.
|
||||||
* Note: this is not the number of bigrams output in the array, which is the number of
|
* Note: this is not the number of bigrams output in the array, which is the number of
|
||||||
* bigrams this word has WHOSE first letter also matches the letter the user typed.
|
* bigrams this word has WHOSE first letter also matches the letter the user typed.
|
||||||
|
@ -103,7 +102,7 @@ bool BigramDictionary::addWordBigram(unsigned short *word, int length, int frequ
|
||||||
*/
|
*/
|
||||||
int BigramDictionary::getBigrams(unsigned short *prevWord, int prevWordLength, int *codes,
|
int BigramDictionary::getBigrams(unsigned short *prevWord, int prevWordLength, int *codes,
|
||||||
int codesSize, unsigned short *bigramChars, int *bigramFreq, int maxWordLength,
|
int codesSize, unsigned short *bigramChars, int *bigramFreq, int maxWordLength,
|
||||||
int maxBigrams, int maxAlternatives) {
|
int maxBigrams) {
|
||||||
// TODO: remove unused arguments, and refrain from storing stuff in members of this class
|
// TODO: remove unused arguments, and refrain from storing stuff in members of this class
|
||||||
// TODO: have "in" arguments before "out" ones, and make out args explicit in the name
|
// TODO: have "in" arguments before "out" ones, and make out args explicit in the name
|
||||||
mBigramFreq = bigramFreq;
|
mBigramFreq = bigramFreq;
|
||||||
|
|
|
@ -22,11 +22,10 @@ namespace latinime {
|
||||||
class Dictionary;
|
class Dictionary;
|
||||||
class BigramDictionary {
|
class BigramDictionary {
|
||||||
public:
|
public:
|
||||||
BigramDictionary(const unsigned char *dict, int maxWordLength, int maxAlternatives,
|
BigramDictionary(const unsigned char *dict, int maxWordLength,
|
||||||
const bool isLatestDictVersion, const bool hasBigram, Dictionary *parentDictionary);
|
const bool isLatestDictVersion, const bool hasBigram, Dictionary *parentDictionary);
|
||||||
int getBigrams(unsigned short *word, int length, int *codes, int codesSize,
|
int getBigrams(unsigned short *word, int length, int *codes, int codesSize,
|
||||||
unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams,
|
unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams);
|
||||||
int maxAlternatives);
|
|
||||||
~BigramDictionary();
|
~BigramDictionary();
|
||||||
private:
|
private:
|
||||||
bool addWordBigram(unsigned short *word, int length, int frequency);
|
bool addWordBigram(unsigned short *word, int length, int frequency);
|
||||||
|
@ -39,7 +38,8 @@ class BigramDictionary {
|
||||||
|
|
||||||
const unsigned char *DICT;
|
const unsigned char *DICT;
|
||||||
const int MAX_WORD_LENGTH;
|
const int MAX_WORD_LENGTH;
|
||||||
const int MAX_ALTERNATIVES;
|
// TODO: Re-implement proximity correction for bigram correction
|
||||||
|
static const int MAX_ALTERNATIVES = 1;
|
||||||
const bool IS_LATEST_DICT_VERSION;
|
const bool IS_LATEST_DICT_VERSION;
|
||||||
const bool HAS_BIGRAM;
|
const bool HAS_BIGRAM;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace latinime {
|
||||||
// TODO: Change the type of all keyCodes to uint32_t
|
// TODO: Change the type of all keyCodes to uint32_t
|
||||||
Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
|
Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
|
||||||
int typedLetterMultiplier, int fullWordMultiplier,
|
int typedLetterMultiplier, int fullWordMultiplier,
|
||||||
int maxWordLength, int maxWords, int maxAlternatives)
|
int maxWordLength, int maxWords)
|
||||||
: mDict((unsigned char*) dict), mDictSize(dictSize),
|
: mDict((unsigned char*) dict), mDictSize(dictSize),
|
||||||
mMmapFd(mmapFd), mDictBufAdjust(dictBufAdjust),
|
mMmapFd(mmapFd), mDictBufAdjust(dictBufAdjust),
|
||||||
// Checks whether it has the latest dictionary or the old dictionary
|
// Checks whether it has the latest dictionary or the old dictionary
|
||||||
|
@ -44,8 +44,8 @@ Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust,
|
||||||
maxWords, SUB_QUEUE_MAX_WORDS, maxWordLength);
|
maxWords, SUB_QUEUE_MAX_WORDS, maxWordLength);
|
||||||
const unsigned int headerSize = BinaryFormat::getHeaderSize(mDict);
|
const unsigned int headerSize = BinaryFormat::getHeaderSize(mDict);
|
||||||
mUnigramDictionary = new UnigramDictionary(mDict + headerSize, typedLetterMultiplier,
|
mUnigramDictionary = new UnigramDictionary(mDict + headerSize, typedLetterMultiplier,
|
||||||
fullWordMultiplier, maxWordLength, maxWords, maxAlternatives, IS_LATEST_DICT_VERSION);
|
fullWordMultiplier, maxWordLength, maxWords, IS_LATEST_DICT_VERSION);
|
||||||
mBigramDictionary = new BigramDictionary(mDict + headerSize, maxWordLength, maxAlternatives,
|
mBigramDictionary = new BigramDictionary(mDict + headerSize, maxWordLength,
|
||||||
IS_LATEST_DICT_VERSION, true /* hasBigram */, this);
|
IS_LATEST_DICT_VERSION, true /* hasBigram */, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace latinime {
|
||||||
class Dictionary {
|
class Dictionary {
|
||||||
public:
|
public:
|
||||||
Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int typedLetterMultipler,
|
Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int typedLetterMultipler,
|
||||||
int fullWordMultiplier, int maxWordLength, int maxWords, int maxAlternatives);
|
int fullWordMultiplier, int maxWordLength, int maxWords);
|
||||||
|
|
||||||
int getSuggestions(ProximityInfo *proximityInfo, int *xcoordinates, int *ycoordinates,
|
int getSuggestions(ProximityInfo *proximityInfo, int *xcoordinates, int *ycoordinates,
|
||||||
int *codes, int codesSize, int flags, unsigned short *outWords, int *frequencies) {
|
int *codes, int codesSize, int flags, unsigned short *outWords, int *frequencies) {
|
||||||
|
@ -41,10 +41,9 @@ class Dictionary {
|
||||||
|
|
||||||
// TODO: Call mBigramDictionary instead of mUnigramDictionary
|
// TODO: Call mBigramDictionary instead of mUnigramDictionary
|
||||||
int getBigrams(unsigned short *word, int length, int *codes, int codesSize,
|
int getBigrams(unsigned short *word, int length, int *codes, int codesSize,
|
||||||
unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams,
|
unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams) {
|
||||||
int maxAlternatives) {
|
|
||||||
return mBigramDictionary->getBigrams(word, length, codes, codesSize, outWords, frequencies,
|
return mBigramDictionary->getBigrams(word, length, codes, codesSize, outWords, frequencies,
|
||||||
maxWordLength, maxBigrams, maxAlternatives);
|
maxWordLength, maxBigrams);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isValidWord(unsigned short *word, int length);
|
bool isValidWord(unsigned short *word, int length);
|
||||||
|
|
|
@ -40,7 +40,7 @@ const UnigramDictionary::digraph_t UnigramDictionary::FRENCH_LIGATURES_DIGRAPHS[
|
||||||
|
|
||||||
// TODO: check the header
|
// TODO: check the header
|
||||||
UnigramDictionary::UnigramDictionary(const uint8_t* const streamStart, int typedLetterMultiplier,
|
UnigramDictionary::UnigramDictionary(const uint8_t* const streamStart, int typedLetterMultiplier,
|
||||||
int fullWordMultiplier, int maxWordLength, int maxWords, int maxProximityChars,
|
int fullWordMultiplier, int maxWordLength, int maxWords,
|
||||||
const bool isLatestDictVersion)
|
const bool isLatestDictVersion)
|
||||||
: DICT_ROOT(streamStart), MAX_WORD_LENGTH(maxWordLength), MAX_WORDS(maxWords),
|
: DICT_ROOT(streamStart), MAX_WORD_LENGTH(maxWordLength), MAX_WORDS(maxWords),
|
||||||
IS_LATEST_DICT_VERSION(isLatestDictVersion),
|
IS_LATEST_DICT_VERSION(isLatestDictVersion),
|
||||||
|
|
|
@ -74,7 +74,7 @@ class UnigramDictionary {
|
||||||
static const int MAX_ERRORS_FOR_TWO_WORDS = 1;
|
static const int MAX_ERRORS_FOR_TWO_WORDS = 1;
|
||||||
|
|
||||||
UnigramDictionary(const uint8_t* const streamStart, int typedLetterMultipler,
|
UnigramDictionary(const uint8_t* const streamStart, int typedLetterMultipler,
|
||||||
int fullWordMultiplier, int maxWordLength, int maxWords, int maxProximityChars,
|
int fullWordMultiplier, int maxWordLength, int maxWords,
|
||||||
const bool isLatestDictVersion);
|
const bool isLatestDictVersion);
|
||||||
bool isValidWord(const uint16_t* const inWord, const int length) const;
|
bool isValidWord(const uint16_t* const inWord, const int length) const;
|
||||||
int getBigramPosition(int pos, unsigned short *word, int offset, int length) const;
|
int getBigramPosition(int pos, unsigned short *word, int offset, int length) const;
|
||||||
|
|
Loading…
Reference in New Issue