Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ede23336 authored by Tom Ouyang's avatar Tom Ouyang
Browse files

Add method to get dictionary flags from DicTraverseSession

This is needed for the traversal algorithm to know which
digraphs (if any) are associated with the current dictionary.

Bug: 8493920

Change-Id: I6ae088b55e50c0c2c7066d045b304c5068e23390
parent a8d29082
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -103,4 +103,9 @@ int Dictionary::getProbability(const int *word, int length) const {
bool Dictionary::isValidBigram(const int *word1, int length1, const int *word2, int length2) const {
    return mBigramDictionary->isValidBigram(word1, length1, word2, length2);
}

int Dictionary::getDictFlags() const {
    return mUnigramDictionary->getDictFlags();
}

} // namespace latinime
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ class Dictionary {
    int getDictSize() const { return mDictSize; }
    int getMmapFd() const { return mMmapFd; }
    int getDictBufAdjust() const { return mDictBufAdjust; }
    int getDictFlags() const;
    virtual ~Dictionary();

 private:
+4 −0
Original line number Diff line number Diff line
@@ -84,6 +84,10 @@ const uint8_t *DicTraverseSession::getOffsetDict() const {
    return mDictionary->getOffsetDict();
}

int DicTraverseSession::getDictFlags() const {
    return mDictionary->getDictFlags();
}

void DicTraverseSession::resetCache(const int nextActiveCacheSize, const int maxWords) {
    mDicNodesCache.reset(nextActiveCacheSize, maxWords);
    mBigramCacheMap.clear();
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ class DicTraverseSession {
    void resetCache(const int nextActiveCacheSize, const int maxWords);

    const uint8_t *getOffsetDict() const;
    bool canUseCache() const;
    int getDictFlags() const;

    //--------------------
    // getters and setters
+3 −3
Original line number Diff line number Diff line
@@ -32,9 +32,9 @@
namespace latinime {

// TODO: check the header
UnigramDictionary::UnigramDictionary(const uint8_t *const streamStart, const unsigned int flags)
UnigramDictionary::UnigramDictionary(const uint8_t *const streamStart, const unsigned int dictFlags)
        : DICT_ROOT(streamStart), ROOT_POS(0),
          MAX_DIGRAPH_SEARCH_DEPTH(DEFAULT_MAX_DIGRAPH_SEARCH_DEPTH), FLAGS(flags) {
          MAX_DIGRAPH_SEARCH_DEPTH(DEFAULT_MAX_DIGRAPH_SEARCH_DEPTH), DICT_FLAGS(dictFlags) {
    if (DEBUG_DICT) {
        AKLOGI("UnigramDictionary - constructor");
    }
@@ -163,7 +163,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo, const int *x
    masterCorrection.resetCorrection();
    const DigraphUtils::digraph_t *digraphs = 0;
    const int digraphsSize =
            DigraphUtils::getAllDigraphsForDictionaryAndReturnSize(FLAGS, &digraphs);
            DigraphUtils::getAllDigraphsForDictionaryAndReturnSize(DICT_FLAGS, &digraphs);
    if (digraphsSize > 0)
    { // Incrementally tune the word and try all possibilities
        int codesBuffer[sizeof(*inputCodePoints) * inputSize];
Loading