diff options
author | 2013-05-31 00:02:57 +0900 | |
---|---|---|
committer | 2013-05-31 00:02:57 +0900 | |
commit | a65c267b1f1207e54c6f821148c600e3899b7f9c (patch) | |
tree | 1b39021389e1bb93fb60539f816f74a82f333d7a /native/jni/src/dictionary.cpp | |
parent | 7097aa2d3d2fc4d314edebb43edc8a0552517630 (diff) | |
download | latinime-a65c267b1f1207e54c6f821148c600e3899b7f9c.tar.gz latinime-a65c267b1f1207e54c6f821148c600e3899b7f9c.tar.xz latinime-a65c267b1f1207e54c6f821148c600e3899b7f9c.zip |
Move some dictionary related implementations to the dictionary directory
Change-Id: I6fe71a540ad91ca46755be234abc8894242e2413
Diffstat (limited to 'native/jni/src/dictionary.cpp')
-rw-r--r-- | native/jni/src/dictionary.cpp | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/native/jni/src/dictionary.cpp b/native/jni/src/dictionary.cpp deleted file mode 100644 index d9ed0fe49..000000000 --- a/native/jni/src/dictionary.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2009, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "LatinIME: dictionary.cpp" - -#include "dictionary.h" - -#include <map> // TODO: remove -#include <stdint.h> - -#include "bigram_dictionary.h" -#include "binary_format.h" -#include "defines.h" -#include "dic_traverse_wrapper.h" -#include "suggest_options.h" -#include "suggest/core/suggest.h" -#include "suggest/policyimpl/gesture/gesture_suggest_policy_factory.h" -#include "suggest/policyimpl/typing/typing_suggest_policy_factory.h" -#include "unigram_dictionary.h" - -namespace latinime { - -Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust) - : mDict(static_cast<unsigned char *>(dict)), - mOffsetDict((static_cast<unsigned char *>(dict)) - + BinaryFormat::getHeaderSize(mDict, dictSize)), - mDictSize(dictSize), mMmapFd(mmapFd), mDictBufAdjust(dictBufAdjust), - mUnigramDictionary(new UnigramDictionary(mOffsetDict, - BinaryFormat::getFlags(mDict, dictSize))), - mBigramDictionary(new BigramDictionary(mOffsetDict)), - mGestureSuggest(new Suggest(GestureSuggestPolicyFactory::getGestureSuggestPolicy())), - mTypingSuggest(new Suggest(TypingSuggestPolicyFactory::getTypingSuggestPolicy())) { -} - -Dictionary::~Dictionary() { - delete mUnigramDictionary; - delete mBigramDictionary; - delete mGestureSuggest; - delete mTypingSuggest; -} - -int Dictionary::getSuggestions(ProximityInfo *proximityInfo, void *traverseSession, - int *xcoordinates, int *ycoordinates, int *times, int *pointerIds, int *inputCodePoints, - int inputSize, int *prevWordCodePoints, int prevWordLength, int commitPoint, - const SuggestOptions *const suggestOptions, int *outWords, int *frequencies, - int *spaceIndices, int *outputTypes) const { - int result = 0; - if (suggestOptions->isGesture()) { - DicTraverseWrapper::initDicTraverseSession( - traverseSession, this, prevWordCodePoints, prevWordLength, suggestOptions); - result = mGestureSuggest->getSuggestions(proximityInfo, traverseSession, xcoordinates, - ycoordinates, times, pointerIds, inputCodePoints, inputSize, commitPoint, outWords, - frequencies, spaceIndices, outputTypes); - if (DEBUG_DICT) { - DUMP_RESULT(outWords, frequencies); - } - return result; - } else { - if (USE_SUGGEST_INTERFACE_FOR_TYPING) { - DicTraverseWrapper::initDicTraverseSession( - traverseSession, this, prevWordCodePoints, prevWordLength, suggestOptions); - result = mTypingSuggest->getSuggestions(proximityInfo, traverseSession, xcoordinates, - ycoordinates, times, pointerIds, inputCodePoints, inputSize, commitPoint, - outWords, frequencies, spaceIndices, outputTypes); - if (DEBUG_DICT) { - DUMP_RESULT(outWords, frequencies); - } - return result; - } else { - std::map<int, int> bigramMap; - uint8_t bigramFilter[BIGRAM_FILTER_BYTE_SIZE]; - mBigramDictionary->fillBigramAddressToProbabilityMapAndFilter(prevWordCodePoints, - prevWordLength, &bigramMap, bigramFilter); - result = mUnigramDictionary->getSuggestions(proximityInfo, xcoordinates, ycoordinates, - inputCodePoints, inputSize, &bigramMap, bigramFilter, - suggestOptions->useFullEditDistance(), outWords, frequencies, outputTypes); - return result; - } - } -} - -int Dictionary::getBigrams(const int *word, int length, int *inputCodePoints, int inputSize, - int *outWords, int *frequencies, int *outputTypes) const { - if (length <= 0) return 0; - return mBigramDictionary->getBigrams(word, length, inputCodePoints, inputSize, outWords, - frequencies, outputTypes); -} - -int Dictionary::getProbability(const int *word, int length) const { - return mUnigramDictionary->getProbability(word, length); -} - -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 |