am ff981cc3: am 43779c04: Merge "Add method to get dictionary flags from DicTraverseSession"

* commit 'ff981cc3e3169ca0b9af9bf40cd55cd9f95fa63e':
  Add method to get dictionary flags from DicTraverseSession
main
Tom Ouyang 2013-04-17 19:38:34 -07:00 committed by Android Git Automerger
commit 6a0f11cc91
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 { bool Dictionary::isValidBigram(const int *word1, int length1, const int *word2, int length2) const {
return mBigramDictionary->isValidBigram(word1, length1, word2, length2); return mBigramDictionary->isValidBigram(word1, length1, word2, length2);
} }
int Dictionary::getDictFlags() const {
return mUnigramDictionary->getDictFlags();
}
} // namespace latinime } // namespace latinime

View File

@ -63,6 +63,7 @@ class Dictionary {
int getDictSize() const { return mDictSize; } int getDictSize() const { return mDictSize; }
int getMmapFd() const { return mMmapFd; } int getMmapFd() const { return mMmapFd; }
int getDictBufAdjust() const { return mDictBufAdjust; } int getDictBufAdjust() const { return mDictBufAdjust; }
int getDictFlags() const;
virtual ~Dictionary(); virtual ~Dictionary();
private: private:

View File

@ -84,6 +84,10 @@ const uint8_t *DicTraverseSession::getOffsetDict() const {
return mDictionary->getOffsetDict(); return mDictionary->getOffsetDict();
} }
int DicTraverseSession::getDictFlags() const {
return mDictionary->getDictFlags();
}
void DicTraverseSession::resetCache(const int nextActiveCacheSize, const int maxWords) { void DicTraverseSession::resetCache(const int nextActiveCacheSize, const int maxWords) {
mDicNodesCache.reset(nextActiveCacheSize, maxWords); mDicNodesCache.reset(nextActiveCacheSize, maxWords);
mBigramCacheMap.clear(); mBigramCacheMap.clear();

View File

@ -53,7 +53,7 @@ class DicTraverseSession {
void resetCache(const int nextActiveCacheSize, const int maxWords); void resetCache(const int nextActiveCacheSize, const int maxWords);
const uint8_t *getOffsetDict() const; const uint8_t *getOffsetDict() const;
bool canUseCache() const; int getDictFlags() const;
//-------------------- //--------------------
// getters and setters // getters and setters

View File

@ -32,9 +32,9 @@
namespace latinime { namespace latinime {
// TODO: check the header // 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), : 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) { if (DEBUG_DICT) {
AKLOGI("UnigramDictionary - constructor"); AKLOGI("UnigramDictionary - constructor");
} }
@ -163,7 +163,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo, const int *x
masterCorrection.resetCorrection(); masterCorrection.resetCorrection();
const DigraphUtils::digraph_t *digraphs = 0; const DigraphUtils::digraph_t *digraphs = 0;
const int digraphsSize = const int digraphsSize =
DigraphUtils::getAllDigraphsForDictionaryAndReturnSize(FLAGS, &digraphs); DigraphUtils::getAllDigraphsForDictionaryAndReturnSize(DICT_FLAGS, &digraphs);
if (digraphsSize > 0) if (digraphsSize > 0)
{ // Incrementally tune the word and try all possibilities { // Incrementally tune the word and try all possibilities
int codesBuffer[sizeof(*inputCodePoints) * inputSize]; 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_ABORT = 0;
static const int FLAG_MULTIPLE_SUGGEST_SKIP = 1; static const int FLAG_MULTIPLE_SUGGEST_SKIP = 1;
static const int FLAG_MULTIPLE_SUGGEST_CONTINUE = 2; 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 getProbability(const int *const inWord, const int length) const;
int getBigramPosition(int pos, int *word, int offset, int length) const; int getBigramPosition(int pos, int *word, int offset, int length) const;
int getSuggestions(ProximityInfo *proximityInfo, const int *xcoordinates, int getSuggestions(ProximityInfo *proximityInfo, const int *xcoordinates,
@ -46,6 +46,7 @@ class UnigramDictionary {
const std::map<int, int> *bigramMap, const uint8_t *bigramFilter, const std::map<int, int> *bigramMap, const uint8_t *bigramFilter,
const bool useFullEditDistance, int *outWords, int *frequencies, const bool useFullEditDistance, int *outWords, int *frequencies,
int *outputTypes) const; int *outputTypes) const;
int getDictFlags() const { return DICT_FLAGS; }
virtual ~UnigramDictionary(); virtual ~UnigramDictionary();
private: private:
@ -109,7 +110,7 @@ class UnigramDictionary {
const uint8_t *const DICT_ROOT; const uint8_t *const DICT_ROOT;
const int ROOT_POS; const int ROOT_POS;
const int MAX_DIGRAPH_SEARCH_DEPTH; const int MAX_DIGRAPH_SEARCH_DEPTH;
const int FLAGS; const int DICT_FLAGS;
}; };
} // namespace latinime } // namespace latinime
#endif // LATINIME_UNIGRAM_DICTIONARY_H #endif // LATINIME_UNIGRAM_DICTIONARY_H