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
This commit is contained in:
Tom Ouyang 2013-04-02 17:23:13 -07:00
parent a8d2908284
commit ede2333640
6 changed files with 17 additions and 6 deletions

View file

@ -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

View file

@ -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:

View file

@ -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();

View file

@ -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

View file

@ -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];

View file

@ -38,7 +38,7 @@ class UnigramDictionary {
static const int FLAG_MULTIPLE_SUGGEST_ABORT = 0;
static const int FLAG_MULTIPLE_SUGGEST_SKIP = 1;
static const int FLAG_MULTIPLE_SUGGEST_CONTINUE = 2;
UnigramDictionary(const uint8_t *const streamStart, const unsigned int flags);
UnigramDictionary(const uint8_t *const streamStart, const unsigned int dictFlags);
int getProbability(const int *const inWord, const int length) const;
int getBigramPosition(int pos, int *word, int offset, int length) const;
int getSuggestions(ProximityInfo *proximityInfo, const int *xcoordinates,
@ -46,6 +46,7 @@ class UnigramDictionary {
const std::map<int, int> *bigramMap, const uint8_t *bigramFilter,
const bool useFullEditDistance, int *outWords, int *frequencies,
int *outputTypes) const;
int getDictFlags() const { return DICT_FLAGS; }
virtual ~UnigramDictionary();
private:
@ -109,7 +110,7 @@ class UnigramDictionary {
const uint8_t *const DICT_ROOT;
const int ROOT_POS;
const int MAX_DIGRAPH_SEARCH_DEPTH;
const int FLAGS;
const int DICT_FLAGS;
};
} // namespace latinime
#endif // LATINIME_UNIGRAM_DICTIONARY_H