aboutsummaryrefslogtreecommitdiffstats
path: root/native/jni/src
diff options
context:
space:
mode:
Diffstat (limited to 'native/jni/src')
-rw-r--r--native/jni/src/suggest/core/dictionary/bigram_dictionary.cpp8
-rw-r--r--native/jni/src/suggest/core/dictionary/dictionary.cpp33
-rw-r--r--native/jni/src/suggest/core/dictionary/dictionary.h13
3 files changed, 47 insertions, 7 deletions
diff --git a/native/jni/src/suggest/core/dictionary/bigram_dictionary.cpp b/native/jni/src/suggest/core/dictionary/bigram_dictionary.cpp
index 6e02100fc..242a9bdd6 100644
--- a/native/jni/src/suggest/core/dictionary/bigram_dictionary.cpp
+++ b/native/jni/src/suggest/core/dictionary/bigram_dictionary.cpp
@@ -184,13 +184,13 @@ bool BigramDictionary::checkFirstCharacter(int *word, int *inputCodePoints) cons
return false;
}
-bool BigramDictionary::isValidBigram(const int *word1, int length1, const int *word2,
- int length2) const {
- int pos = getBigramListPositionForWord(word1, length1, false /* forceLowerCaseSearch */);
+bool BigramDictionary::isValidBigram(const int *word0, int length0, const int *word1,
+ int length1) const {
+ int pos = getBigramListPositionForWord(word0, length0, false /* forceLowerCaseSearch */);
// getBigramListPositionForWord returns 0 if this word isn't in the dictionary or has no bigrams
if (0 == pos) return false;
int nextWordPos = BinaryFormat::getTerminalPosition(mBinaryDictionaryInfo->getDictRoot(),
- word2, length2, false /* forceLowerCaseSearch */);
+ word1, length1, false /* forceLowerCaseSearch */);
if (NOT_VALID_WORD == nextWordPos) return false;
for (BinaryDictionaryBigramsIterator bigramsIt(mBinaryDictionaryInfo, pos);
diff --git a/native/jni/src/suggest/core/dictionary/dictionary.cpp b/native/jni/src/suggest/core/dictionary/dictionary.cpp
index 028b61506..51f23dc55 100644
--- a/native/jni/src/suggest/core/dictionary/dictionary.cpp
+++ b/native/jni/src/suggest/core/dictionary/dictionary.cpp
@@ -106,8 +106,37 @@ int Dictionary::getProbability(const int *word, int length) const {
return unigramProbability;
}
-bool Dictionary::isValidBigram(const int *word1, int length1, const int *word2, int length2) const {
- return mBigramDictionary->isValidBigram(word1, length1, word2, length2);
+bool Dictionary::isValidBigram(const int *word0, int length0, const int *word1, int length1) const {
+ return mBigramDictionary->isValidBigram(word0, length0, word1, length1);
+}
+
+void Dictionary::addUnigramWord(const int *const word, const int length, const int probability) {
+ if (!mBinaryDictionaryInfo.isDynamicallyUpdatable()) {
+ // This method should not be called for non-updatable dictionary.
+ AKLOGI("Warning: Dictionary::addUnigramWord() is called for non-updatable dictionary.");
+ return;
+ }
+ // TODO: Support dynamic update
+}
+
+void Dictionary::addBigramWords(const int *const word0, const int length0, const int *const word1,
+ const int length1, const int probability) {
+ if (!mBinaryDictionaryInfo.isDynamicallyUpdatable()) {
+ // This method should not be called for non-updatable dictionary.
+ AKLOGI("Warning: Dictionary::addBigramWords() is called for non-updatable dictionary.");
+ return;
+ }
+ // TODO: Support dynamic update
+}
+
+void Dictionary::removeBigramWords(const int *const word0, const int length0,
+ const int *const word1, const int length1) {
+ if (!mBinaryDictionaryInfo.isDynamicallyUpdatable()) {
+ // This method should not be called for non-updatable dictionary.
+ AKLOGI("Warning: Dictionary::removeBigramWords() is called for non-updatable dictionary.");
+ return;
+ }
+ // TODO: Support dynamic update
}
} // namespace latinime
diff --git a/native/jni/src/suggest/core/dictionary/dictionary.h b/native/jni/src/suggest/core/dictionary/dictionary.h
index afd081841..94579c200 100644
--- a/native/jni/src/suggest/core/dictionary/dictionary.h
+++ b/native/jni/src/suggest/core/dictionary/dictionary.h
@@ -64,10 +64,21 @@ class Dictionary {
int *frequencies, int *outputTypes) const;
int getProbability(const int *word, int length) const;
- bool isValidBigram(const int *word1, int length1, const int *word2, int length2) const;
+
+ bool isValidBigram(const int *word0, int length0, const int *word1, int length1) const;
+
+ void addUnigramWord(const int *const word, const int length, const int probability);
+
+ void addBigramWords(const int *const word0, const int length0, const int *const word1,
+ const int length1, const int probability);
+
+ void removeBigramWords(const int *const word0, const int length0, const int *const word1,
+ const int length1);
+
const BinaryDictionaryInfo *getBinaryDictionaryInfo() const {
return &mBinaryDictionaryInfo;
}
+
virtual ~Dictionary();
private: