aboutsummaryrefslogtreecommitdiffstats
path: root/native/src/dictionary.h
diff options
context:
space:
mode:
Diffstat (limited to 'native/src/dictionary.h')
-rw-r--r--native/src/dictionary.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/native/src/dictionary.h b/native/src/dictionary.h
index 3749f3d88..2c574290f 100644
--- a/native/src/dictionary.h
+++ b/native/src/dictionary.h
@@ -28,12 +28,19 @@ namespace latinime {
// if the word has other endings.
#define FLAG_TERMINAL_MASK 0x80
+#define FLAG_BIGRAM_READ 0x80
+#define FLAG_BIGRAM_CHILDEXIST 0x40
+#define FLAG_BIGRAM_CONTINUED 0x80
+#define FLAG_BIGRAM_FREQ 0x7F
+
class Dictionary {
public:
Dictionary(void *dict, int typedLetterMultipler, int fullWordMultiplier);
int getSuggestions(int *codes, int codesSize, unsigned short *outWords, int *frequencies,
int maxWordLength, int maxWords, int maxAlternatives, int skipPos,
int *nextLetters, int nextLettersSize);
+ int getBigrams(unsigned short *word, int length, unsigned short *outWords, int *frequencies,
+ int maxWordLength, int maxBigrams);
bool isValidWord(unsigned short *word, int length);
void setAsset(void *asset) { mAsset = asset; }
void *getAsset() { return mAsset; }
@@ -41,28 +48,40 @@ public:
private:
+ void getVersionNumber();
+ bool checkIfDictVersionIsLatest();
int getAddress(int *pos);
+ int getBigramAddress(int *pos, bool advance);
+ int getFreq(int *pos);
+ int getBigramFreq(int *pos);
+ void searchForTerminalNode(int address, int frequency);
+
+ bool getFirstBitOfByte(int *pos) { return (mDict[*pos] & 0x80) > 0; }
+ bool getSecondBitOfByte(int *pos) { return (mDict[*pos] & 0x40) > 0; }
bool getTerminal(int *pos) { return (mDict[*pos] & FLAG_TERMINAL_MASK) > 0; }
- int getFreq(int *pos) { return mDict[(*pos)++] & 0xFF; }
int getCount(int *pos) { return mDict[(*pos)++] & 0xFF; }
unsigned short getChar(int *pos);
int wideStrLen(unsigned short *str);
bool sameAsTyped(unsigned short *word, int length);
bool addWord(unsigned short *word, int length, int frequency);
+ bool addWordBigram(unsigned short *word, int length, int frequency);
unsigned short toLowerCase(unsigned short c);
void getWordsRec(int pos, int depth, int maxDepth, bool completion, int frequency,
int inputIndex, int diffs);
- bool isValidWordRec(int pos, unsigned short *word, int offset, int length);
+ int isValidWordRec(int pos, unsigned short *word, int offset, int length);
void registerNextLetter(unsigned short c);
unsigned char *mDict;
void *mAsset;
int *mFrequencies;
+ int *mBigramFreq;
int mMaxWords;
+ int mMaxBigrams;
int mMaxWordLength;
unsigned short *mOutputChars;
+ unsigned short *mBigramChars;
int *mInputCodes;
int mInputLength;
int mMaxAlternatives;
@@ -74,6 +93,8 @@ private:
int mTypedLetterMultiplier;
int *mNextLettersFrequencies;
int mNextLettersSize;
+ int mVersion;
+ int mBigram;
};
// ----------------------------------------------------------------------------