diff --git a/native/jni/src/suggest/core/dictionary/dictionary.cpp b/native/jni/src/suggest/core/dictionary/dictionary.cpp index fb25f757cb42b48acf5e8044acdfb53d56100c61..4605409cce69e1f4dc1b3cdf688d6481a6c8e829 100644 --- a/native/jni/src/suggest/core/dictionary/dictionary.cpp +++ b/native/jni/src/suggest/core/dictionary/dictionary.cpp @@ -94,7 +94,7 @@ int Dictionary::getProbability(const int *word, int length) const { if (NOT_A_DICT_POS == pos) { return NOT_A_PROBABILITY; } - return getDictionaryStructurePolicy()->getUnigramProbabilityOfPtNode(pos); + return getDictionaryStructurePolicy()->getProbabilityOfPtNode(nullptr /* prevWordsInfo */, pos); } int Dictionary::getMaxProbabilityOfExactMatches(const int *word, int length) const { @@ -116,8 +116,8 @@ int Dictionary::getNgramProbability(const PrevWordsInfo *const prevWordsInfo, co if (bigramsIt.getBigramPos() == nextWordPos && bigramsIt.getProbability() != NOT_A_PROBABILITY) { return mDictionaryStructureWithBufferPolicy->getProbability( - mDictionaryStructureWithBufferPolicy->getUnigramProbabilityOfPtNode( - nextWordPos), bigramsIt.getProbability()); + mDictionaryStructureWithBufferPolicy->getProbabilityOfPtNode( + nullptr /* prevWordsInfo */, nextWordPos), bigramsIt.getProbability()); } } return NOT_A_PROBABILITY; diff --git a/native/jni/src/suggest/core/policy/dictionary_structure_with_buffer_policy.h b/native/jni/src/suggest/core/policy/dictionary_structure_with_buffer_policy.h index a48d64473dcf52809a3bc86e998984c32a069498..7ad20e782249ccb5a58c3f6d36d6fedcfef01c6a 100644 --- a/native/jni/src/suggest/core/policy/dictionary_structure_with_buffer_policy.h +++ b/native/jni/src/suggest/core/policy/dictionary_structure_with_buffer_policy.h @@ -58,7 +58,8 @@ class DictionaryStructureWithBufferPolicy { virtual int getProbability(const int unigramProbability, const int bigramProbability) const = 0; - virtual int getUnigramProbabilityOfPtNode(const int nodePos) const = 0; + virtual int getProbabilityOfPtNode(const PrevWordsInfo *const prevWordsInfo, + const int nodePos) const = 0; virtual int getShortcutPositionOfPtNode(const int nodePos) const = 0; diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/ver4_patricia_trie_policy.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/ver4_patricia_trie_policy.cpp index f478d9b91219a2f2bccf55e90ea1d177c9fb8044..88199455253588a41b47d76bd2f30f2319c90752 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/ver4_patricia_trie_policy.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/ver4_patricia_trie_policy.cpp @@ -131,7 +131,8 @@ int Ver4PatriciaTriePolicy::getProbability(const int unigramProbability, } } -int Ver4PatriciaTriePolicy::getUnigramProbabilityOfPtNode(const int ptNodePos) const { +int Ver4PatriciaTriePolicy::getProbabilityOfPtNode(const PrevWordsInfo *const prevWordsInfo, + const int ptNodePos) const { if (ptNodePos == NOT_A_DICT_POS) { return NOT_A_PROBABILITY; } diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/ver4_patricia_trie_policy.h b/native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/ver4_patricia_trie_policy.h index 6d97c7cc8e763280b8041acfd0076ef6fbb7da5c..c80a73af76bb5bb93b4b878fbafff51b0e02a715 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/ver4_patricia_trie_policy.h +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/backward/v402/ver4_patricia_trie_policy.h @@ -90,7 +90,8 @@ class Ver4PatriciaTriePolicy : public DictionaryStructureWithBufferPolicy { int getProbability(const int unigramProbability, const int bigramProbability) const; - int getUnigramProbabilityOfPtNode(const int ptNodePos) const; + int getProbabilityOfPtNode(const PrevWordsInfo *const prevWordsInfo, + const int ptNodePos) const; int getShortcutPositionOfPtNode(const int ptNodePos) const; diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.cpp index 531cbb710187c7cb3e9580daa796fe05b8732f83..53550a432f07b5f6d07fdc375c0054c24b8b4d17 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.cpp @@ -295,7 +295,12 @@ int PatriciaTriePolicy::getProbability(const int unigramProbability, } } -int PatriciaTriePolicy::getUnigramProbabilityOfPtNode(const int ptNodePos) const { +int PatriciaTriePolicy::getProbabilityOfPtNode(const PrevWordsInfo *const prevWordsInfo, + const int ptNodePos) const { + if (prevWordsInfo) { + // TODO: Return probability using prevWordsInfo. + return NOT_A_PROBABILITY; + } if (ptNodePos == NOT_A_DICT_POS) { return NOT_A_PROBABILITY; } diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.h b/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.h index d40b9af8dbfca3eed8c802c0b9792035b1208ca1..1dd5705be9a042768b4a292b217fce0749a0653f 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.h +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v2/patricia_trie_policy.h @@ -63,7 +63,7 @@ class PatriciaTriePolicy : public DictionaryStructureWithBufferPolicy { int getProbability(const int unigramProbability, const int bigramProbability) const; - int getUnigramProbabilityOfPtNode(const int ptNodePos) const; + int getProbabilityOfPtNode(const PrevWordsInfo *const prevWordsInfo, const int ptNodePos) const; int getShortcutPositionOfPtNode(const int ptNodePos) const; diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_policy.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_policy.cpp index 0b5764aba0a970f024e76379bc6c73937395f5a7..5197a4dd504fee04b29aebf860e46e387168164b 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_policy.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_policy.cpp @@ -121,7 +121,12 @@ int Ver4PatriciaTriePolicy::getProbability(const int unigramProbability, } } -int Ver4PatriciaTriePolicy::getUnigramProbabilityOfPtNode(const int ptNodePos) const { +int Ver4PatriciaTriePolicy::getProbabilityOfPtNode(const PrevWordsInfo *const prevWordsInfo, + const int ptNodePos) const { + if (prevWordsInfo) { + // TODO: Return probability using prevWordsInfo. + return NOT_A_PROBABILITY; + } if (ptNodePos == NOT_A_DICT_POS) { return NOT_A_PROBABILITY; } diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_policy.h b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_policy.h index 85929b7857dced13f1181c05ce52c9ca1950e9f1..b0f16cd01d9fb310a9ffcf32bd2ca3530122f8fd 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_policy.h +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_patricia_trie_policy.h @@ -72,7 +72,7 @@ class Ver4PatriciaTriePolicy : public DictionaryStructureWithBufferPolicy { int getProbability(const int unigramProbability, const int bigramProbability) const; - int getUnigramProbabilityOfPtNode(const int ptNodePos) const; + int getProbabilityOfPtNode(const PrevWordsInfo *const prevWordsInfo, const int ptNodePos) const; int getShortcutPositionOfPtNode(const int ptNodePos) const;