Remove flags from dicNodeProperties.
Bug: 6669677 Change-Id: I6f4aef8c4e4376f078ed8375394823788aa35002main
parent
9aa1efdf46
commit
5b03213db1
|
@ -112,32 +112,23 @@ class DicNode {
|
||||||
mIsUsed = true;
|
mIsUsed = true;
|
||||||
mIsCachedForNextSuggestion = false;
|
mIsCachedForNextSuggestion = false;
|
||||||
mDicNodeProperties.init(
|
mDicNodeProperties.init(
|
||||||
NOT_A_DICT_POS, 0 /* flags */, rootGroupPos, NOT_A_DICT_POS /* attributesPos */,
|
NOT_A_DICT_POS, rootGroupPos, NOT_A_DICT_POS /* attributesPos */,
|
||||||
NOT_A_CODE_POINT /* nodeCodePoint */, NOT_A_PROBABILITY /* probability */,
|
NOT_A_CODE_POINT /* nodeCodePoint */, NOT_A_PROBABILITY /* probability */,
|
||||||
false /* isTerminal */, true /* hasChildren */, 0 /* depth */,
|
false /* isTerminal */, true /* hasChildren */,
|
||||||
0 /* terminalDepth */);
|
false /* isBlacklistedOrNotAWord */, 0 /* depth */, 0 /* terminalDepth */);
|
||||||
mDicNodeState.init(prevWordNodePos);
|
mDicNodeState.init(prevWordNodePos);
|
||||||
PROF_NODE_RESET(mProfiler);
|
PROF_NODE_RESET(mProfiler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initAsPassingChild(DicNode *parentNode) {
|
|
||||||
mIsUsed = true;
|
|
||||||
mIsCachedForNextSuggestion = parentNode->mIsCachedForNextSuggestion;
|
|
||||||
const int c = parentNode->getNodeTypedCodePoint();
|
|
||||||
mDicNodeProperties.init(&parentNode->mDicNodeProperties, c);
|
|
||||||
mDicNodeState.init(&parentNode->mDicNodeState);
|
|
||||||
PROF_NODE_COPY(&parentNode->mProfiler, mProfiler);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init for root with previous word
|
// Init for root with previous word
|
||||||
void initAsRootWithPreviousWord(DicNode *dicNode, const int rootGroupPos) {
|
void initAsRootWithPreviousWord(DicNode *dicNode, const int rootGroupPos) {
|
||||||
mIsUsed = true;
|
mIsUsed = true;
|
||||||
mIsCachedForNextSuggestion = dicNode->mIsCachedForNextSuggestion;
|
mIsCachedForNextSuggestion = dicNode->mIsCachedForNextSuggestion;
|
||||||
mDicNodeProperties.init(
|
mDicNodeProperties.init(
|
||||||
NOT_A_DICT_POS, 0 /* flags */, rootGroupPos, NOT_A_DICT_POS /* attributesPos */,
|
NOT_A_DICT_POS, rootGroupPos, NOT_A_DICT_POS /* attributesPos */,
|
||||||
NOT_A_CODE_POINT /* nodeCodePoint */, NOT_A_PROBABILITY /* probability */,
|
NOT_A_CODE_POINT /* nodeCodePoint */, NOT_A_PROBABILITY /* probability */,
|
||||||
false /* isTerminal */, true /* hasChildren */, 0 /* depth */,
|
false /* isTerminal */, true /* hasChildren */,
|
||||||
0 /* terminalDepth */);
|
false /* isBlacklistedOrNotAWord */, 0 /* depth */, 0 /* terminalDepth */);
|
||||||
// TODO: Move to dicNodeState?
|
// TODO: Move to dicNodeState?
|
||||||
mDicNodeState.mDicNodeStateOutput.init(); // reset for next word
|
mDicNodeState.mDicNodeStateOutput.init(); // reset for next word
|
||||||
mDicNodeState.mDicNodeStateInput.init(
|
mDicNodeState.mDicNodeStateInput.init(
|
||||||
|
@ -157,18 +148,27 @@ class DicNode {
|
||||||
PROF_NODE_COPY(&dicNode->mProfiler, mProfiler);
|
PROF_NODE_COPY(&dicNode->mProfiler, mProfiler);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: minimize arguments by looking binary_format
|
void initAsPassingChild(DicNode *parentNode) {
|
||||||
void initAsChild(DicNode *dicNode, const int pos, const uint8_t flags, const int childrenPos,
|
mIsUsed = true;
|
||||||
|
mIsCachedForNextSuggestion = parentNode->mIsCachedForNextSuggestion;
|
||||||
|
const int c = parentNode->getNodeTypedCodePoint();
|
||||||
|
mDicNodeProperties.init(&parentNode->mDicNodeProperties, c);
|
||||||
|
mDicNodeState.init(&parentNode->mDicNodeState);
|
||||||
|
PROF_NODE_COPY(&parentNode->mProfiler, mProfiler);
|
||||||
|
}
|
||||||
|
|
||||||
|
void initAsChild(DicNode *dicNode, const int pos, const int childrenPos,
|
||||||
const int attributesPos, const int probability, const bool isTerminal,
|
const int attributesPos, const int probability, const bool isTerminal,
|
||||||
const bool hasChildren, const uint16_t mergedNodeCodePointCount,
|
const bool hasChildren, const bool isBlacklistedOrNotAWord,
|
||||||
const int *const mergedNodeCodePoints) {
|
const uint16_t mergedNodeCodePointCount, const int *const mergedNodeCodePoints) {
|
||||||
mIsUsed = true;
|
mIsUsed = true;
|
||||||
uint16_t newDepth = static_cast<uint16_t>(dicNode->getNodeCodePointCount() + 1);
|
uint16_t newDepth = static_cast<uint16_t>(dicNode->getNodeCodePointCount() + 1);
|
||||||
mIsCachedForNextSuggestion = dicNode->mIsCachedForNextSuggestion;
|
mIsCachedForNextSuggestion = dicNode->mIsCachedForNextSuggestion;
|
||||||
const uint16_t newLeavingDepth = static_cast<uint16_t>(
|
const uint16_t newLeavingDepth = static_cast<uint16_t>(
|
||||||
dicNode->mDicNodeProperties.getLeavingDepth() + mergedNodeCodePointCount);
|
dicNode->mDicNodeProperties.getLeavingDepth() + mergedNodeCodePointCount);
|
||||||
mDicNodeProperties.init(pos, flags, childrenPos, attributesPos, mergedNodeCodePoints[0],
|
mDicNodeProperties.init(pos, childrenPos, attributesPos, mergedNodeCodePoints[0],
|
||||||
probability, isTerminal, hasChildren, newDepth, newLeavingDepth);
|
probability, isTerminal, hasChildren, isBlacklistedOrNotAWord, newDepth,
|
||||||
|
newLeavingDepth);
|
||||||
mDicNodeState.init(&dicNode->mDicNodeState, mergedNodeCodePointCount,
|
mDicNodeState.init(&dicNode->mDicNodeState, mergedNodeCodePointCount,
|
||||||
mergedNodeCodePoints);
|
mergedNodeCodePoints);
|
||||||
PROF_NODE_COPY(&dicNode->mProfiler, mProfiler);
|
PROF_NODE_COPY(&dicNode->mProfiler, mProfiler);
|
||||||
|
@ -216,7 +216,7 @@ class DicNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isImpossibleBigramWord() const {
|
bool isImpossibleBigramWord() const {
|
||||||
if (mDicNodeProperties.hasBlacklistedOrNotAWordFlag()) {
|
if (isBlacklistedOrNotAWord()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const int prevWordLen = mDicNodeState.mDicNodeStatePrevWord.getPrevWordLength()
|
const int prevWordLen = mDicNodeState.mDicNodeStatePrevWord.getPrevWordLength()
|
||||||
|
@ -463,8 +463,8 @@ class DicNode {
|
||||||
return mDicNodeState.mDicNodeStateScoring.isExactMatch();
|
return mDicNodeState.mDicNodeStateScoring.isExactMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getFlags() const {
|
bool isBlacklistedOrNotAWord() const {
|
||||||
return mDicNodeProperties.getFlags();
|
return mDicNodeProperties.isBlacklistedOrNotAWord();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getAttributesPos() const {
|
int getAttributesPos() const {
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "suggest/core/dictionary/binary_format.h"
|
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
|
@ -32,24 +31,25 @@ namespace latinime {
|
||||||
class DicNodeProperties {
|
class DicNodeProperties {
|
||||||
public:
|
public:
|
||||||
AK_FORCE_INLINE DicNodeProperties()
|
AK_FORCE_INLINE DicNodeProperties()
|
||||||
: mPos(0), mFlags(0), mChildrenPos(0), mAttributesPos(0), mProbability(0),
|
: mPos(0), mChildrenPos(0), mAttributesPos(0), mProbability(0),
|
||||||
mNodeCodePoint(0), mDepth(0), mLeavingDepth(0), mIsTerminal(false),
|
mNodeCodePoint(0), mIsTerminal(false), mHasChildren(false),
|
||||||
mHasChildren(false) {}
|
mIsBlacklistedOrNotAWord(false), mDepth(0), mLeavingDepth(0) {}
|
||||||
|
|
||||||
virtual ~DicNodeProperties() {}
|
virtual ~DicNodeProperties() {}
|
||||||
|
|
||||||
// Should be called only once per DicNode is initialized.
|
// Should be called only once per DicNode is initialized.
|
||||||
void init(const int pos, const uint8_t flags, const int childrenPos, const int attributesPos,
|
void init(const int pos, const int childrenPos, const int attributesPos,
|
||||||
const int nodeCodePoint, const int probability, const bool isTerminal,
|
const int nodeCodePoint, const int probability, const bool isTerminal,
|
||||||
const bool hasChildren, const uint16_t depth, const uint16_t leavingDepth) {
|
const bool hasChildren, const bool isBlacklistedOrNotAWord,
|
||||||
|
const uint16_t depth, const uint16_t leavingDepth) {
|
||||||
mPos = pos;
|
mPos = pos;
|
||||||
mFlags = flags;
|
|
||||||
mChildrenPos = childrenPos;
|
mChildrenPos = childrenPos;
|
||||||
mAttributesPos = attributesPos;
|
mAttributesPos = attributesPos;
|
||||||
mNodeCodePoint = nodeCodePoint;
|
mNodeCodePoint = nodeCodePoint;
|
||||||
mProbability = probability;
|
mProbability = probability;
|
||||||
mIsTerminal = isTerminal;
|
mIsTerminal = isTerminal;
|
||||||
mHasChildren = hasChildren;
|
mHasChildren = hasChildren;
|
||||||
|
mIsBlacklistedOrNotAWord = isBlacklistedOrNotAWord;
|
||||||
mDepth = depth;
|
mDepth = depth;
|
||||||
mLeavingDepth = leavingDepth;
|
mLeavingDepth = leavingDepth;
|
||||||
}
|
}
|
||||||
|
@ -57,13 +57,13 @@ class DicNodeProperties {
|
||||||
// Init for copy
|
// Init for copy
|
||||||
void init(const DicNodeProperties *const nodeProp) {
|
void init(const DicNodeProperties *const nodeProp) {
|
||||||
mPos = nodeProp->mPos;
|
mPos = nodeProp->mPos;
|
||||||
mFlags = nodeProp->mFlags;
|
|
||||||
mChildrenPos = nodeProp->mChildrenPos;
|
mChildrenPos = nodeProp->mChildrenPos;
|
||||||
mAttributesPos = nodeProp->mAttributesPos;
|
mAttributesPos = nodeProp->mAttributesPos;
|
||||||
mNodeCodePoint = nodeProp->mNodeCodePoint;
|
mNodeCodePoint = nodeProp->mNodeCodePoint;
|
||||||
mProbability = nodeProp->mProbability;
|
mProbability = nodeProp->mProbability;
|
||||||
mIsTerminal = nodeProp->mIsTerminal;
|
mIsTerminal = nodeProp->mIsTerminal;
|
||||||
mHasChildren = nodeProp->mHasChildren;
|
mHasChildren = nodeProp->mHasChildren;
|
||||||
|
mIsBlacklistedOrNotAWord = nodeProp->mIsBlacklistedOrNotAWord;
|
||||||
mDepth = nodeProp->mDepth;
|
mDepth = nodeProp->mDepth;
|
||||||
mLeavingDepth = nodeProp->mLeavingDepth;
|
mLeavingDepth = nodeProp->mLeavingDepth;
|
||||||
}
|
}
|
||||||
|
@ -71,13 +71,13 @@ class DicNodeProperties {
|
||||||
// Init as passing child
|
// Init as passing child
|
||||||
void init(const DicNodeProperties *const nodeProp, const int codePoint) {
|
void init(const DicNodeProperties *const nodeProp, const int codePoint) {
|
||||||
mPos = nodeProp->mPos;
|
mPos = nodeProp->mPos;
|
||||||
mFlags = nodeProp->mFlags;
|
|
||||||
mChildrenPos = nodeProp->mChildrenPos;
|
mChildrenPos = nodeProp->mChildrenPos;
|
||||||
mAttributesPos = nodeProp->mAttributesPos;
|
mAttributesPos = nodeProp->mAttributesPos;
|
||||||
mNodeCodePoint = codePoint; // Overwrite the node char of a passing child
|
mNodeCodePoint = codePoint; // Overwrite the node char of a passing child
|
||||||
mProbability = nodeProp->mProbability;
|
mProbability = nodeProp->mProbability;
|
||||||
mIsTerminal = nodeProp->mIsTerminal;
|
mIsTerminal = nodeProp->mIsTerminal;
|
||||||
mHasChildren = nodeProp->mHasChildren;
|
mHasChildren = nodeProp->mHasChildren;
|
||||||
|
mIsBlacklistedOrNotAWord = nodeProp->mIsBlacklistedOrNotAWord;
|
||||||
mDepth = nodeProp->mDepth + 1; // Increment the depth of a passing child
|
mDepth = nodeProp->mDepth + 1; // Increment the depth of a passing child
|
||||||
mLeavingDepth = nodeProp->mLeavingDepth;
|
mLeavingDepth = nodeProp->mLeavingDepth;
|
||||||
}
|
}
|
||||||
|
@ -86,10 +86,6 @@ class DicNodeProperties {
|
||||||
return mPos;
|
return mPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getFlags() const {
|
|
||||||
return mFlags;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getChildrenPos() const {
|
int getChildrenPos() const {
|
||||||
return mChildrenPos;
|
return mChildrenPos;
|
||||||
}
|
}
|
||||||
|
@ -123,8 +119,8 @@ class DicNodeProperties {
|
||||||
return mHasChildren || mDepth != mLeavingDepth;
|
return mHasChildren || mDepth != mLeavingDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasBlacklistedOrNotAWordFlag() const {
|
bool isBlacklistedOrNotAWord() const {
|
||||||
return BinaryFormat::hasBlacklistedOrNotAWordFlag(mFlags);
|
return mIsBlacklistedOrNotAWord;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -132,15 +128,15 @@ class DicNodeProperties {
|
||||||
// Use a default copy constructor and an assign operator because shallow copies are ok
|
// Use a default copy constructor and an assign operator because shallow copies are ok
|
||||||
// for this class
|
// for this class
|
||||||
int mPos;
|
int mPos;
|
||||||
uint8_t mFlags;
|
|
||||||
int mChildrenPos;
|
int mChildrenPos;
|
||||||
int mAttributesPos;
|
int mAttributesPos;
|
||||||
int mProbability;
|
int mProbability;
|
||||||
int mNodeCodePoint;
|
int mNodeCodePoint;
|
||||||
uint16_t mDepth;
|
|
||||||
uint16_t mLeavingDepth;
|
|
||||||
bool mIsTerminal;
|
bool mIsTerminal;
|
||||||
bool mHasChildren;
|
bool mHasChildren;
|
||||||
|
bool mIsBlacklistedOrNotAWord;
|
||||||
|
uint16_t mDepth;
|
||||||
|
uint16_t mLeavingDepth;
|
||||||
};
|
};
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
#endif // LATINIME_DIC_NODE_PROPERTIES_H
|
#endif // LATINIME_DIC_NODE_PROPERTIES_H
|
||||||
|
|
|
@ -78,6 +78,7 @@ namespace latinime {
|
||||||
const bool isTerminal = (0 != (BinaryFormat::FLAG_IS_TERMINAL & flags));
|
const bool isTerminal = (0 != (BinaryFormat::FLAG_IS_TERMINAL & flags));
|
||||||
const bool hasChildren = BinaryFormat::hasChildrenInFlags(flags);
|
const bool hasChildren = BinaryFormat::hasChildrenInFlags(flags);
|
||||||
const bool hasShortcuts = (0 != (BinaryFormat::FLAG_HAS_SHORTCUT_TARGETS & flags));
|
const bool hasShortcuts = (0 != (BinaryFormat::FLAG_HAS_SHORTCUT_TARGETS & flags));
|
||||||
|
const bool isBlacklistedOrNotAWord = BinaryFormat::hasBlacklistedOrNotAWordFlag(flags);
|
||||||
|
|
||||||
int codePoint = BinaryFormat::getCodePointAndForwardPointer(
|
int codePoint = BinaryFormat::getCodePointAndForwardPointer(
|
||||||
binaryDictionaryInfo->getDictRoot(), &pos);
|
binaryDictionaryInfo->getDictRoot(), &pos);
|
||||||
|
@ -111,8 +112,9 @@ namespace latinime {
|
||||||
if (childrenFilter->isFilteredOut(mergedNodeCodePoints[0])) {
|
if (childrenFilter->isFilteredOut(mergedNodeCodePoints[0])) {
|
||||||
return siblingPos;
|
return siblingPos;
|
||||||
}
|
}
|
||||||
childDicNodes->pushLeavingChild(dicNode, nextPos, flags, childrenPos, attributesPos,
|
childDicNodes->pushLeavingChild(dicNode, nextPos, childrenPos, attributesPos,
|
||||||
probability, isTerminal, hasChildren, mergedNodeCodePointCount, mergedNodeCodePoints);
|
probability, isTerminal, hasChildren, isBlacklistedOrNotAWord,
|
||||||
|
mergedNodeCodePointCount, mergedNodeCodePoints);
|
||||||
return siblingPos;
|
return siblingPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,14 +62,15 @@ class DicNodeVector {
|
||||||
mDicNodes.back().initAsPassingChild(dicNode);
|
mDicNodes.back().initAsPassingChild(dicNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pushLeavingChild(DicNode *dicNode, const int pos, const uint8_t flags,
|
void pushLeavingChild(DicNode *dicNode, const int pos, const int childrenPos,
|
||||||
const int childrenPos, const int attributesPos, const int probability,
|
const int attributesPos, const int probability, const bool isTerminal,
|
||||||
const bool isTerminal, const bool hasChildren, const uint16_t mergedNodeCodePointCount,
|
const bool hasChildren, const bool isBlacklistedOrNotAWord,
|
||||||
const int *const mergedNodeCodePoints) {
|
const uint16_t mergedNodeCodePointCount, const int *const mergedNodeCodePoints) {
|
||||||
ASSERT(!mLock);
|
ASSERT(!mLock);
|
||||||
mDicNodes.push_back(mEmptyNode);
|
mDicNodes.push_back(mEmptyNode);
|
||||||
mDicNodes.back().initAsChild(dicNode, pos, flags, childrenPos, attributesPos, probability,
|
mDicNodes.back().initAsChild(dicNode, pos, childrenPos, attributesPos, probability,
|
||||||
isTerminal, hasChildren, mergedNodeCodePointCount, mergedNodeCodePoints);
|
isTerminal, hasChildren, isBlacklistedOrNotAWord, mergedNodeCodePointCount,
|
||||||
|
mergedNodeCodePoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
DicNode *operator[](const int id) {
|
DicNode *operator[](const int id) {
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include "suggest/core/dictionary/binary_dictionary_info.h"
|
#include "suggest/core/dictionary/binary_dictionary_info.h"
|
||||||
#include "suggest/core/dictionary/binary_dictionary_terminal_attributes_reading_utils.h"
|
#include "suggest/core/dictionary/binary_dictionary_terminal_attributes_reading_utils.h"
|
||||||
#include "suggest/core/dictionary/binary_format.h"
|
|
||||||
|
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
|
@ -71,13 +70,12 @@ class TerminalAttributes {
|
||||||
};
|
};
|
||||||
|
|
||||||
TerminalAttributes(const BinaryDictionaryInfo *const binaryDictionaryInfo,
|
TerminalAttributes(const BinaryDictionaryInfo *const binaryDictionaryInfo,
|
||||||
const uint8_t nodeFlags, const int shortcutPos)
|
const int shortcutPos)
|
||||||
: mBinaryDictionaryInfo(binaryDictionaryInfo),
|
: mBinaryDictionaryInfo(binaryDictionaryInfo), mShortcutListSizePos(shortcutPos) {}
|
||||||
mNodeFlags(nodeFlags), mShortcutListSizePos(shortcutPos) {}
|
|
||||||
|
|
||||||
inline ShortcutIterator getShortcutIterator() const {
|
inline ShortcutIterator getShortcutIterator() const {
|
||||||
int shortcutPos = mShortcutListSizePos;
|
int shortcutPos = mShortcutListSizePos;
|
||||||
const bool hasShortcutList = 0 != (mNodeFlags & BinaryFormat::FLAG_HAS_SHORTCUT_TARGETS);
|
const bool hasShortcutList = shortcutPos != NOT_A_DICT_POS;
|
||||||
if (hasShortcutList) {
|
if (hasShortcutList) {
|
||||||
BinaryDictionaryTerminalAttributesReadingUtils::getShortcutListSizeAndForwardPointer(
|
BinaryDictionaryTerminalAttributesReadingUtils::getShortcutListSizeAndForwardPointer(
|
||||||
mBinaryDictionaryInfo, &shortcutPos);
|
mBinaryDictionaryInfo, &shortcutPos);
|
||||||
|
@ -86,14 +84,9 @@ class TerminalAttributes {
|
||||||
return ShortcutIterator(mBinaryDictionaryInfo, shortcutPos, hasShortcutList);
|
return ShortcutIterator(mBinaryDictionaryInfo, shortcutPos, hasShortcutList);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isBlacklistedOrNotAWord() const {
|
|
||||||
return BinaryFormat::hasBlacklistedOrNotAWordFlag(mNodeFlags);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_IMPLICIT_CONSTRUCTORS(TerminalAttributes);
|
DISALLOW_IMPLICIT_CONSTRUCTORS(TerminalAttributes);
|
||||||
const BinaryDictionaryInfo *const mBinaryDictionaryInfo;
|
const BinaryDictionaryInfo *const mBinaryDictionaryInfo;
|
||||||
const uint8_t mNodeFlags;
|
|
||||||
const int mShortcutListSizePos;
|
const int mShortcutListSizePos;
|
||||||
};
|
};
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
|
|
|
@ -173,8 +173,6 @@ int Suggest::outputSuggestions(DicTraverseSession *traverseSession, int *frequen
|
||||||
terminalIndex, doubleLetterTerminalIndex, doubleLetterLevel);
|
terminalIndex, doubleLetterTerminalIndex, doubleLetterLevel);
|
||||||
const float compoundDistance = terminalDicNode->getCompoundDistance(languageWeight)
|
const float compoundDistance = terminalDicNode->getCompoundDistance(languageWeight)
|
||||||
+ doubleLetterCost;
|
+ doubleLetterCost;
|
||||||
const TerminalAttributes terminalAttributes(traverseSession->getBinaryDictionaryInfo(),
|
|
||||||
terminalDicNode->getFlags(), terminalDicNode->getAttributesPos());
|
|
||||||
const bool isPossiblyOffensiveWord = terminalDicNode->getProbability() <= 0;
|
const bool isPossiblyOffensiveWord = terminalDicNode->getProbability() <= 0;
|
||||||
const bool isExactMatch = terminalDicNode->isExactMatch();
|
const bool isExactMatch = terminalDicNode->isExactMatch();
|
||||||
const bool isFirstCharUppercase = terminalDicNode->isFirstCharUppercase();
|
const bool isFirstCharUppercase = terminalDicNode->isFirstCharUppercase();
|
||||||
|
@ -187,7 +185,7 @@ int Suggest::outputSuggestions(DicTraverseSession *traverseSession, int *frequen
|
||||||
| (isSafeExactMatch ? Dictionary::KIND_FLAG_EXACT_MATCH : 0);
|
| (isSafeExactMatch ? Dictionary::KIND_FLAG_EXACT_MATCH : 0);
|
||||||
|
|
||||||
// Entries that are blacklisted or do not represent a word should not be output.
|
// Entries that are blacklisted or do not represent a word should not be output.
|
||||||
const bool isValidWord = !terminalAttributes.isBlacklistedOrNotAWord();
|
const bool isValidWord = !terminalDicNode->isBlacklistedOrNotAWord();
|
||||||
|
|
||||||
// Increase output score of top typing suggestion to ensure autocorrection.
|
// Increase output score of top typing suggestion to ensure autocorrection.
|
||||||
// TODO: Better integration with java side autocorrection logic.
|
// TODO: Better integration with java side autocorrection logic.
|
||||||
|
@ -233,6 +231,8 @@ int Suggest::outputSuggestions(DicTraverseSession *traverseSession, int *frequen
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!terminalDicNode->hasMultipleWords()) {
|
if (!terminalDicNode->hasMultipleWords()) {
|
||||||
|
const TerminalAttributes terminalAttributes(traverseSession->getBinaryDictionaryInfo(),
|
||||||
|
terminalDicNode->getAttributesPos());
|
||||||
// Shortcut is not supported for multiple words suggestions.
|
// Shortcut is not supported for multiple words suggestions.
|
||||||
// TODO: Check shortcuts during traversal for multiple words suggestions.
|
// TODO: Check shortcuts during traversal for multiple words suggestions.
|
||||||
const bool sameAsTyped = TRAVERSAL->sameAsTyped(traverseSession, terminalDicNode);
|
const bool sameAsTyped = TRAVERSAL->sameAsTyped(traverseSession, terminalDicNode);
|
||||||
|
|
Loading…
Reference in New Issue