aboutsummaryrefslogtreecommitdiffstats
path: root/native/jni/src/suggest
diff options
context:
space:
mode:
Diffstat (limited to 'native/jni/src/suggest')
-rw-r--r--native/jni/src/suggest/core/dicnode/dic_node.h26
-rw-r--r--native/jni/src/suggest/core/dicnode/dic_node_state_scoring.h23
-rw-r--r--native/jni/src/suggest/core/dictionary/shortcut_utils.h2
-rw-r--r--native/jni/src/suggest/core/policy/traversal.h3
-rw-r--r--native/jni/src/suggest/core/policy/weighting.cpp11
-rw-r--r--native/jni/src/suggest/core/policy/weighting.h1
-rw-r--r--native/jni/src/suggest/core/session/dic_traverse_session.cpp9
-rw-r--r--native/jni/src/suggest/core/session/dic_traverse_session.h4
-rw-r--r--native/jni/src/suggest/core/suggest.cpp47
-rw-r--r--native/jni/src/suggest/core/suggest.h14
-rw-r--r--native/jni/src/suggest/core/suggest_interface.h (renamed from native/jni/src/suggest/suggest_interface.h)0
-rw-r--r--native/jni/src/suggest/gesture_suggest.h61
-rw-r--r--native/jni/src/suggest/policyimpl/gesture/gesture_suggest_policy_factory.cpp (renamed from native/jni/src/suggest/typing_suggest.cpp)8
-rw-r--r--native/jni/src/suggest/policyimpl/gesture/gesture_suggest_policy_factory.h44
-rw-r--r--native/jni/src/suggest/policyimpl/typing/scoring_params.cpp2
-rw-r--r--native/jni/src/suggest/policyimpl/typing/typing_scoring.cpp2
-rw-r--r--native/jni/src/suggest/policyimpl/typing/typing_scoring.h4
-rw-r--r--native/jni/src/suggest/policyimpl/typing/typing_suggest_policy.cpp23
-rw-r--r--native/jni/src/suggest/policyimpl/typing/typing_suggest_policy.h8
-rw-r--r--native/jni/src/suggest/policyimpl/typing/typing_suggest_policy_factory.h (renamed from native/jni/src/suggest/gesture_suggest.cpp)22
-rw-r--r--native/jni/src/suggest/policyimpl/typing/typing_traversal.cpp2
-rw-r--r--native/jni/src/suggest/policyimpl/typing/typing_traversal.h10
-rw-r--r--native/jni/src/suggest/policyimpl/typing/typing_weighting.cpp7
-rw-r--r--native/jni/src/suggest/policyimpl/typing/typing_weighting.h7
-rw-r--r--native/jni/src/suggest/typing_suggest.h61
25 files changed, 193 insertions, 208 deletions
diff --git a/native/jni/src/suggest/core/dicnode/dic_node.h b/native/jni/src/suggest/core/dicnode/dic_node.h
index 7bfa459a2..32faae52c 100644
--- a/native/jni/src/suggest/core/dicnode/dic_node.h
+++ b/native/jni/src/suggest/core/dicnode/dic_node.h
@@ -23,6 +23,7 @@
#include "dic_node_profiler.h"
#include "dic_node_properties.h"
#include "dic_node_release_listener.h"
+#include "digraph_utils.h"
#if DEBUG_DICT
#define LOGI_SHOW_ADD_COST_PROP \
@@ -48,13 +49,6 @@
namespace latinime {
-// Naming convention
-// - Distance: "Weighted" edit distance -- used both for spatial and language.
-// - Compound Distance: Spatial Distance + Language Distance -- used for pruning and scoring
-// - Cost: delta/diff for Distance -- used both for spatial and language
-// - Length: "Non-weighted" -- used only for spatial
-// - Probability: "Non-weighted" -- used only for language
-
// This struct is purely a bucket to return values. No instances of this struct should be kept.
struct DicNode_InputStateG {
bool mNeedsToUpdateInputStateG;
@@ -406,8 +400,15 @@ class DicNode {
// TODO: Remove //
//////////////////////
// TODO: Remove once touch path is merged into ProximityInfoState
+ // Note: Returned codepoint may be a digraph codepoint if the node is in a composite glyph.
int getNodeCodePoint() const {
- return mDicNodeProperties.getNodeCodePoint();
+ const int codePoint = mDicNodeProperties.getNodeCodePoint();
+ const DigraphUtils::DigraphCodePointIndex digraphIndex =
+ mDicNodeState.mDicNodeStateScoring.getDigraphIndex();
+ if (digraphIndex == DigraphUtils::NOT_A_DIGRAPH_INDEX) {
+ return codePoint;
+ }
+ return DigraphUtils::getDigraphCodePointForIndex(codePoint, digraphIndex);
}
////////////////////////////////
@@ -459,6 +460,15 @@ class DicNode {
mDicNodeState.mDicNodeStateScoring.setDoubleLetterLevel(doubleLetterLevel);
}
+ bool isInDigraph() const {
+ return mDicNodeState.mDicNodeStateScoring.getDigraphIndex()
+ != DigraphUtils::NOT_A_DIGRAPH_INDEX;
+ }
+
+ void advanceDigraphIndex() {
+ mDicNodeState.mDicNodeStateScoring.advanceDigraphIndex();
+ }
+
uint8_t getFlags() const {
return mDicNodeProperties.getFlags();
}
diff --git a/native/jni/src/suggest/core/dicnode/dic_node_state_scoring.h b/native/jni/src/suggest/core/dicnode/dic_node_state_scoring.h
index 8e816329f..8902d3122 100644
--- a/native/jni/src/suggest/core/dicnode/dic_node_state_scoring.h
+++ b/native/jni/src/suggest/core/dicnode/dic_node_state_scoring.h
@@ -20,6 +20,7 @@
#include <stdint.h>
#include "defines.h"
+#include "digraph_utils.h"
namespace latinime {
@@ -27,6 +28,7 @@ class DicNodeStateScoring {
public:
AK_FORCE_INLINE DicNodeStateScoring()
: mDoubleLetterLevel(NOT_A_DOUBLE_LETTER),
+ mDigraphIndex(DigraphUtils::NOT_A_DIGRAPH_INDEX),
mEditCorrectionCount(0), mProximityCorrectionCount(0),
mNormalizedCompoundDistance(0.0f), mSpatialDistance(0.0f), mLanguageDistance(0.0f),
mTotalPrevWordsLanguageCost(0.0f), mRawLength(0.0f) {
@@ -43,6 +45,7 @@ class DicNodeStateScoring {
mTotalPrevWordsLanguageCost = 0.0f;
mRawLength = 0.0f;
mDoubleLetterLevel = NOT_A_DOUBLE_LETTER;
+ mDigraphIndex = DigraphUtils::NOT_A_DIGRAPH_INDEX;
}
AK_FORCE_INLINE void init(const DicNodeStateScoring *const scoring) {
@@ -54,6 +57,7 @@ class DicNodeStateScoring {
mTotalPrevWordsLanguageCost = scoring->mTotalPrevWordsLanguageCost;
mRawLength = scoring->mRawLength;
mDoubleLetterLevel = scoring->mDoubleLetterLevel;
+ mDigraphIndex = scoring->mDigraphIndex;
}
void addCost(const float spatialCost, const float languageCost, const bool doNormalization,
@@ -126,6 +130,24 @@ class DicNodeStateScoring {
}
}
+ DigraphUtils::DigraphCodePointIndex getDigraphIndex() const {
+ return mDigraphIndex;
+ }
+
+ void advanceDigraphIndex() {
+ switch(mDigraphIndex) {
+ case DigraphUtils::NOT_A_DIGRAPH_INDEX:
+ mDigraphIndex = DigraphUtils::FIRST_DIGRAPH_CODEPOINT;
+ break;
+ case DigraphUtils::FIRST_DIGRAPH_CODEPOINT:
+ mDigraphIndex = DigraphUtils::SECOND_DIGRAPH_CODEPOINT;
+ break;
+ case DigraphUtils::SECOND_DIGRAPH_CODEPOINT:
+ mDigraphIndex = DigraphUtils::NOT_A_DIGRAPH_INDEX;
+ break;
+ }
+ }
+
float getTotalPrevWordsLanguageCost() const {
return mTotalPrevWordsLanguageCost;
}
@@ -135,6 +157,7 @@ class DicNodeStateScoring {
// Use a default copy constructor and an assign operator because shallow copies are ok
// for this class
DoubleLetterLevel mDoubleLetterLevel;
+ DigraphUtils::DigraphCodePointIndex mDigraphIndex;
int16_t mEditCorrectionCount;
int16_t mProximityCorrectionCount;
diff --git a/native/jni/src/suggest/core/dictionary/shortcut_utils.h b/native/jni/src/suggest/core/dictionary/shortcut_utils.h
index e592136cc..c411408ec 100644
--- a/native/jni/src/suggest/core/dictionary/shortcut_utils.h
+++ b/native/jni/src/suggest/core/dictionary/shortcut_utils.h
@@ -18,7 +18,7 @@
#define LATINIME_SHORTCUT_UTILS
#include "defines.h"
-#include "dic_node_utils.h"
+#include "suggest/core/dicnode/dic_node_utils.h"
#include "terminal_attributes.h"
namespace latinime {
diff --git a/native/jni/src/suggest/core/policy/traversal.h b/native/jni/src/suggest/core/policy/traversal.h
index 1d5082ff8..02c358aec 100644
--- a/native/jni/src/suggest/core/policy/traversal.h
+++ b/native/jni/src/suggest/core/policy/traversal.h
@@ -20,6 +20,9 @@
#include "defines.h"
namespace latinime {
+
+class DicTraverseSession;
+
class Traversal {
public:
virtual int getMaxPointerCount() const = 0;
diff --git a/native/jni/src/suggest/core/policy/weighting.cpp b/native/jni/src/suggest/core/policy/weighting.cpp
index 4d08fa0fa..e62b70423 100644
--- a/native/jni/src/suggest/core/policy/weighting.cpp
+++ b/native/jni/src/suggest/core/policy/weighting.cpp
@@ -14,14 +14,15 @@
* limitations under the License.
*/
+#include "suggest/core/policy/weighting.h"
+
#include "char_utils.h"
#include "defines.h"
-#include "dic_node.h"
-#include "dic_node_profiler.h"
-#include "dic_node_utils.h"
-#include "dic_traverse_session.h"
#include "hash_map_compat.h"
-#include "weighting.h"
+#include "suggest/core/dicnode/dic_node.h"
+#include "suggest/core/dicnode/dic_node_profiler.h"
+#include "suggest/core/dicnode/dic_node_utils.h"
+#include "suggest/core/session/dic_traverse_session.h"
namespace latinime {
diff --git a/native/jni/src/suggest/core/policy/weighting.h b/native/jni/src/suggest/core/policy/weighting.h
index 83a0f4b45..b92dbe278 100644
--- a/native/jni/src/suggest/core/policy/weighting.h
+++ b/native/jni/src/suggest/core/policy/weighting.h
@@ -18,6 +18,7 @@
#define LATINIME_WEIGHTING_H
#include "defines.h"
+#include "hash_map_compat.h"
namespace latinime {
diff --git a/native/jni/src/suggest/core/session/dic_traverse_session.cpp b/native/jni/src/suggest/core/session/dic_traverse_session.cpp
index 1f781dd43..5b783a2ba 100644
--- a/native/jni/src/suggest/core/session/dic_traverse_session.cpp
+++ b/native/jni/src/suggest/core/session/dic_traverse_session.cpp
@@ -14,12 +14,13 @@
* limitations under the License.
*/
+#include "suggest/core/session/dic_traverse_session.h"
+
#include "defines.h"
#include "dictionary.h"
-#include "dic_node_utils.h"
-#include "dic_traverse_session.h"
#include "dic_traverse_wrapper.h"
#include "jni.h"
+#include "suggest/core/dicnode/dic_node_utils.h"
namespace latinime {
@@ -83,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();
diff --git a/native/jni/src/suggest/core/session/dic_traverse_session.h b/native/jni/src/suggest/core/session/dic_traverse_session.h
index af036f82b..525d198cd 100644
--- a/native/jni/src/suggest/core/session/dic_traverse_session.h
+++ b/native/jni/src/suggest/core/session/dic_traverse_session.h
@@ -21,10 +21,10 @@
#include <vector>
#include "defines.h"
-#include "dic_nodes_cache.h"
#include "hash_map_compat.h"
#include "jni.h"
#include "proximity_info_state.h"
+#include "suggest/core/dicnode/dic_nodes_cache.h"
namespace latinime {
@@ -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
diff --git a/native/jni/src/suggest/core/suggest.cpp b/native/jni/src/suggest/core/suggest.cpp
index 7fba1d504..63bb20004 100644
--- a/native/jni/src/suggest/core/suggest.cpp
+++ b/native/jni/src/suggest/core/suggest.cpp
@@ -14,18 +14,21 @@
* limitations under the License.
*/
+#include "suggest/core/suggest.h"
+
#include "char_utils.h"
#include "dictionary.h"
-#include "dic_node_priority_queue.h"
-#include "dic_node_vector.h"
-#include "dic_traverse_session.h"
+#include "digraph_utils.h"
#include "proximity_info.h"
-#include "scoring.h"
-#include "shortcut_utils.h"
-#include "suggest.h"
+#include "suggest/core/dicnode/dic_node.h"
+#include "suggest/core/dicnode/dic_node_priority_queue.h"
+#include "suggest/core/dicnode/dic_node_vector.h"
+#include "suggest/core/dictionary/shortcut_utils.h"
+#include "suggest/core/policy/scoring.h"
+#include "suggest/core/policy/traversal.h"
+#include "suggest/core/policy/weighting.h"
+#include "suggest/core/session/dic_traverse_session.h"
#include "terminal_attributes.h"
-#include "traversal.h"
-#include "weighting.h"
namespace latinime {
@@ -219,7 +222,7 @@ int Suggest::outputSuggestions(DicTraverseSession *traverseSession, int *frequen
void Suggest::expandCurrentDicNodes(DicTraverseSession *traverseSession) const {
const int inputSize = traverseSession->getInputSize();
DicNodeVector childDicNodes(TRAVERSAL->getDefaultExpandDicNodeSize());
- DicNode omissionDicNode;
+ DicNode correctionDicNode;
// TODO: Find more efficient caching
const bool shouldDepthLevelCache = TRAVERSAL->shouldDepthLevelCache(traverseSession);
@@ -255,7 +258,10 @@ void Suggest::expandCurrentDicNodes(DicTraverseSession *traverseSession) const {
dicNode.setCached();
}
- if (isLookAheadCorrection) {
+ if (dicNode.isInDigraph()) {
+ // Finish digraph handling if the node is in the middle of a digraph expansion.
+ processDicNodeAsDigraph(traverseSession, &dicNode);
+ } else if (isLookAheadCorrection) {
// The algorithm maintains a small set of "deferred" nodes that have not consumed the
// latest touch point yet. These are needed to apply look-ahead correction operations
// that require special handling of the latest touch point. For example, with insertions
@@ -289,12 +295,18 @@ void Suggest::expandCurrentDicNodes(DicTraverseSession *traverseSession) const {
processDicNodeAsMatch(traverseSession, childDicNode);
continue;
}
+ if (DigraphUtils::hasDigraphForCodePoint(traverseSession->getDictFlags(),
+ childDicNode->getNodeCodePoint())) {
+ correctionDicNode.initByCopy(childDicNode);
+ correctionDicNode.advanceDigraphIndex();
+ processDicNodeAsDigraph(traverseSession, &correctionDicNode);
+ }
if (allowsErrorCorrections
&& TRAVERSAL->isOmission(traverseSession, &dicNode, childDicNode)) {
// TODO: (Gesture) Change weight between omission and substitution errors
// TODO: (Gesture) Terminal node should not be handled as omission
- omissionDicNode.initByCopy(childDicNode);
- processDicNodeAsOmission(traverseSession, &omissionDicNode);
+ correctionDicNode.initByCopy(childDicNode);
+ processDicNodeAsOmission(traverseSession, &correctionDicNode);
}
const ProximityType proximityType = TRAVERSAL->getProximityType(
traverseSession, &dicNode, childDicNode);
@@ -398,6 +410,16 @@ void Suggest::processDicNodeAsSubstitution(DicTraverseSession *traverseSession,
processExpandedDicNode(traverseSession, childDicNode);
}
+// Process the node codepoint as a digraph. This means that composite glyphs like the German
+// u-umlaut is expanded to the transliteration "ue". Note that this happens in parallel with
+// the normal non-digraph traversal, so both "uber" and "ueber" can be corrected to "[u-umlaut]ber".
+void Suggest::processDicNodeAsDigraph(DicTraverseSession *traverseSession,
+ DicNode *childDicNode) const {
+ weightChildNode(traverseSession, childDicNode);
+ childDicNode->advanceDigraphIndex();
+ processExpandedDicNode(traverseSession, childDicNode);
+}
+
/**
* Handle the dicNode as an omission error (e.g., ths => this). Skip the current letter and consider
* matches for all possible next letters. Note that just skipping the current letter without any
@@ -424,7 +446,6 @@ void Suggest::processDicNodeAsOmission(
weightChildNode(traverseSession, childDicNode);
if (!TRAVERSAL->isPossibleOmissionChildNode(traverseSession, dicNode, childDicNode)) {
- DicNode::managedDelete(childDicNode);
continue;
}
processExpandedDicNode(traverseSession, childDicNode);
diff --git a/native/jni/src/suggest/core/suggest.h b/native/jni/src/suggest/core/suggest.h
index 75d646bdd..136c4e548 100644
--- a/native/jni/src/suggest/core/suggest.h
+++ b/native/jni/src/suggest/core/suggest.h
@@ -18,11 +18,20 @@
#define LATINIME_SUGGEST_IMPL_H
#include "defines.h"
-#include "suggest_interface.h"
-#include "suggest_policy.h"
+#include "suggest/core/suggest_interface.h"
+#include "suggest/core/policy/suggest_policy.h"
namespace latinime {
+// Naming convention
+// - Distance: "Weighted" edit distance -- used both for spatial and language.
+// - Compound Distance: Spatial Distance + Language Distance -- used for pruning and scoring
+// - Cost: delta/diff for Distance -- used both for spatial and language
+// - Length: "Non-weighted" -- used only for spatial
+// - Probability: "Non-weighted" -- used only for language
+// - Score: Final calibrated score based on the compound distance, which is sent to java as the
+// priority of a suggested word
+
class DicNode;
class DicTraverseSession;
class ProximityInfo;
@@ -55,6 +64,7 @@ class Suggest : public SuggestInterface {
void generateFeatures(
DicTraverseSession *traverseSession, DicNode *dicNode, float *features) const;
void processDicNodeAsOmission(DicTraverseSession *traverseSession, DicNode *dicNode) const;
+ void processDicNodeAsDigraph(DicTraverseSession *traverseSession, DicNode *dicNode) const;
void processDicNodeAsTransposition(DicTraverseSession *traverseSession,
DicNode *dicNode) const;
void processDicNodeAsInsertion(DicTraverseSession *traverseSession, DicNode *dicNode) const;
diff --git a/native/jni/src/suggest/suggest_interface.h b/native/jni/src/suggest/core/suggest_interface.h
index 0bb85d7e5..0bb85d7e5 100644
--- a/native/jni/src/suggest/suggest_interface.h
+++ b/native/jni/src/suggest/core/suggest_interface.h
diff --git a/native/jni/src/suggest/gesture_suggest.h b/native/jni/src/suggest/gesture_suggest.h
deleted file mode 100644
index 82c3a69ad..000000000
--- a/native/jni/src/suggest/gesture_suggest.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#ifndef LATINIME_GESTURE_SUGGEST_H
-#define LATINIME_GESTURE_SUGGEST_H
-
-#include "defines.h"
-#include "suggest_interface.h"
-
-namespace latinime {
-
-class ProximityInfo;
-
-class GestureSuggest : public SuggestInterface {
- public:
- GestureSuggest() : mSuggestInterface(getGestureSuggestInstance()) {}
-
- virtual ~GestureSuggest();
-
- int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs,
- int *times, int *pointerIds, int *inputCodePoints, int inputSize, int commitPoint,
- int *outWords, int *frequencies, int *outputIndices, int *outputTypes) const {
- if (!mSuggestInterface) {
- return 0;
- }
- return mSuggestInterface->getSuggestions(pInfo, traverseSession, inputXs, inputYs, times,
- pointerIds, inputCodePoints, inputSize, commitPoint, outWords, frequencies,
- outputIndices, outputTypes);
- }
-
- static void setGestureSuggestFactoryMethod(SuggestInterface *(*factoryMethod)()) {
- sGestureSuggestFactoryMethod = factoryMethod;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(GestureSuggest);
- static SuggestInterface *getGestureSuggestInstance() {
- if (!sGestureSuggestFactoryMethod) {
- return 0;
- }
- return sGestureSuggestFactoryMethod();
- }
-
- static SuggestInterface *(*sGestureSuggestFactoryMethod)();
- SuggestInterface *mSuggestInterface;
-};
-} // namespace latinime
-#endif // LATINIME_GESTURE_SUGGEST_H
diff --git a/native/jni/src/suggest/typing_suggest.cpp b/native/jni/src/suggest/policyimpl/gesture/gesture_suggest_policy_factory.cpp
index 56bd5b69a..6d3173937 100644
--- a/native/jni/src/suggest/typing_suggest.cpp
+++ b/native/jni/src/suggest/policyimpl/gesture/gesture_suggest_policy_factory.cpp
@@ -14,12 +14,8 @@
* limitations under the License.
*/
-#include "typing_suggest.h"
+#include "gesture_suggest_policy_factory.h"
namespace latinime {
- SuggestInterface *(*TypingSuggest::sTypingSuggestFactoryMethod)() = 0;
-
- TypingSuggest::~TypingSuggest() {
- delete mSuggestInterface;
- }
+ const SuggestPolicy *(*GestureSuggestPolicyFactory::sGestureSuggestFactoryMethod)() = 0;
} // namespace latinime
diff --git a/native/jni/src/suggest/policyimpl/gesture/gesture_suggest_policy_factory.h b/native/jni/src/suggest/policyimpl/gesture/gesture_suggest_policy_factory.h
new file mode 100644
index 000000000..509b01fc0
--- /dev/null
+++ b/native/jni/src/suggest/policyimpl/gesture/gesture_suggest_policy_factory.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#ifndef LATINIME_GESTURE_SUGGEST_POLICY_FACTORY_H
+#define LATINIME_GESTURE_SUGGEST_POLICY_FACTORY_H
+
+#include "defines.h"
+
+namespace latinime {
+
+class SuggestPolicy;
+
+class GestureSuggestPolicyFactory {
+ public:
+ static void setGestureSuggestPolicyFactoryMethod(const SuggestPolicy *(*factoryMethod)()) {
+ sGestureSuggestFactoryMethod = factoryMethod;
+ }
+
+ static const SuggestPolicy *getGestureSuggestPolicy() {
+ if (!sGestureSuggestFactoryMethod) {
+ return 0;
+ }
+ return sGestureSuggestFactoryMethod();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(GestureSuggestPolicyFactory);
+ static const SuggestPolicy *(*sGestureSuggestFactoryMethod)();
+};
+} // namespace latinime
+#endif // LATINIME_GESTURE_SUGGEST_POLICY_FACTORY_H
diff --git a/native/jni/src/suggest/policyimpl/typing/scoring_params.cpp b/native/jni/src/suggest/policyimpl/typing/scoring_params.cpp
index 90985d0fe..0fa684f01 100644
--- a/native/jni/src/suggest/policyimpl/typing/scoring_params.cpp
+++ b/native/jni/src/suggest/policyimpl/typing/scoring_params.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "scoring_params.h"
+#include "suggest/policyimpl/typing/scoring_params.h"
namespace latinime {
// TODO: RENAME all
diff --git a/native/jni/src/suggest/policyimpl/typing/typing_scoring.cpp b/native/jni/src/suggest/policyimpl/typing/typing_scoring.cpp
index 53f68f20f..d8c6175e2 100644
--- a/native/jni/src/suggest/policyimpl/typing/typing_scoring.cpp
+++ b/native/jni/src/suggest/policyimpl/typing/typing_scoring.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "typing_scoring.h"
+#include "suggest/policyimpl/typing/typing_scoring.h"
namespace latinime {
const TypingScoring TypingScoring::sInstance;
diff --git a/native/jni/src/suggest/policyimpl/typing/typing_scoring.h b/native/jni/src/suggest/policyimpl/typing/typing_scoring.h
index ed941f0ae..90e2133e7 100644
--- a/native/jni/src/suggest/policyimpl/typing/typing_scoring.h
+++ b/native/jni/src/suggest/policyimpl/typing/typing_scoring.h
@@ -18,8 +18,8 @@
#define LATINIME_TYPING_SCORING_H
#include "defines.h"
-#include "scoring.h"
-#include "scoring_params.h"
+#include "suggest/core/policy/scoring.h"
+#include "suggest/policyimpl/typing/scoring_params.h"
namespace latinime {
diff --git a/native/jni/src/suggest/policyimpl/typing/typing_suggest_policy.cpp b/native/jni/src/suggest/policyimpl/typing/typing_suggest_policy.cpp
index ebba37531..0c2763967 100644
--- a/native/jni/src/suggest/policyimpl/typing/typing_suggest_policy.cpp
+++ b/native/jni/src/suggest/policyimpl/typing/typing_suggest_policy.cpp
@@ -14,29 +14,8 @@
* limitations under the License.
*/
-#include "suggest.h"
-#include "typing_suggest.h"
-#include "typing_suggest_policy.h"
+#include "suggest/policyimpl/typing/typing_suggest_policy.h"
namespace latinime {
-
const TypingSuggestPolicy TypingSuggestPolicy::sInstance;
-
-// A factory method for a "typing" Suggest instance
-static SuggestInterface *getTypingSuggestInstance() {
- return new Suggest(TypingSuggestPolicy::getInstance());
-}
-
-// An ad-hoc internal class to register the factory method getTypingSuggestInstance() defined above
-class TypingSuggestFactoryRegisterer {
- public:
- TypingSuggestFactoryRegisterer() {
- TypingSuggest::setTypingSuggestFactoryMethod(getTypingSuggestInstance);
- }
- private:
- DISALLOW_COPY_AND_ASSIGN(TypingSuggestFactoryRegisterer);
-};
-
-// To invoke the TypingSuggestFactoryRegisterer's constructor in the global constructor
-static TypingSuggestFactoryRegisterer typingSuggestFactoryregisterer;
} // namespace latinime
diff --git a/native/jni/src/suggest/policyimpl/typing/typing_suggest_policy.h b/native/jni/src/suggest/policyimpl/typing/typing_suggest_policy.h
index 55668fc25..35f48097c 100644
--- a/native/jni/src/suggest/policyimpl/typing/typing_suggest_policy.h
+++ b/native/jni/src/suggest/policyimpl/typing/typing_suggest_policy.h
@@ -18,10 +18,10 @@
#define LATINIME_TYPING_SUGGEST_POLICY_H
#include "defines.h"
-#include "suggest_policy.h"
-#include "typing_scoring.h"
-#include "typing_traversal.h"
-#include "typing_weighting.h"
+#include "suggest/core/policy/suggest_policy.h"
+#include "suggest/policyimpl/typing/typing_scoring.h"
+#include "suggest/policyimpl/typing/typing_traversal.h"
+#include "suggest/policyimpl/typing/typing_weighting.h"
namespace latinime {
diff --git a/native/jni/src/suggest/gesture_suggest.cpp b/native/jni/src/suggest/policyimpl/typing/typing_suggest_policy_factory.h
index fce5621d5..a67b45b1b 100644
--- a/native/jni/src/suggest/gesture_suggest.cpp
+++ b/native/jni/src/suggest/policyimpl/typing/typing_suggest_policy_factory.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013 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.
@@ -14,12 +14,24 @@
* limitations under the License.
*/
-#include "gesture_suggest.h"
+#ifndef LATINIME_TYPING_SUGGEST_POLICY_FACTORY_H
+#define LATINIME_TYPING_SUGGEST_POLICY_FACTORY_H
+
+#include "defines.h"
+#include "typing_suggest_policy.h"
namespace latinime {
- SuggestInterface *(*GestureSuggest::sGestureSuggestFactoryMethod)() = 0;
- GestureSuggest::~GestureSuggest() {
- delete mSuggestInterface;
+class SuggestPolicy;
+
+class TypingSuggestPolicyFactory {
+ public:
+ static const SuggestPolicy *getTypingSuggestPolicy() {
+ return TypingSuggestPolicy::getInstance();
}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TypingSuggestPolicyFactory);
+};
} // namespace latinime
+#endif // LATINIME_TYPING_SUGGEST_POLICY_FACTORY_H
diff --git a/native/jni/src/suggest/policyimpl/typing/typing_traversal.cpp b/native/jni/src/suggest/policyimpl/typing/typing_traversal.cpp
index 68c614e77..66f8ba9fa 100644
--- a/native/jni/src/suggest/policyimpl/typing/typing_traversal.cpp
+++ b/native/jni/src/suggest/policyimpl/typing/typing_traversal.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "typing_traversal.h"
+#include "suggest/policyimpl/typing/typing_traversal.h"
namespace latinime {
const bool TypingTraversal::CORRECT_OMISSION = true;
diff --git a/native/jni/src/suggest/policyimpl/typing/typing_traversal.h b/native/jni/src/suggest/policyimpl/typing/typing_traversal.h
index 16153f8bb..f22029a2c 100644
--- a/native/jni/src/suggest/policyimpl/typing/typing_traversal.h
+++ b/native/jni/src/suggest/policyimpl/typing/typing_traversal.h
@@ -21,12 +21,12 @@
#include "char_utils.h"
#include "defines.h"
-#include "dic_node.h"
-#include "dic_node_vector.h"
-#include "dic_traverse_session.h"
#include "proximity_info_state.h"
-#include "scoring_params.h"
-#include "traversal.h"
+#include "suggest/core/dicnode/dic_node.h"
+#include "suggest/core/dicnode/dic_node_vector.h"
+#include "suggest/core/policy/traversal.h"
+#include "suggest/core/session/dic_traverse_session.h"
+#include "suggest/policyimpl/typing/scoring_params.h"
namespace latinime {
class TypingTraversal : public Traversal {
diff --git a/native/jni/src/suggest/policyimpl/typing/typing_weighting.cpp b/native/jni/src/suggest/policyimpl/typing/typing_weighting.cpp
index 6e4b2fb6a..1500341bd 100644
--- a/native/jni/src/suggest/policyimpl/typing/typing_weighting.cpp
+++ b/native/jni/src/suggest/policyimpl/typing/typing_weighting.cpp
@@ -14,9 +14,10 @@
* limitations under the License.
*/
-#include "dic_node.h"
-#include "scoring_params.h"
-#include "typing_weighting.h"
+#include "suggest/policyimpl/typing/typing_weighting.h"
+
+#include "suggest/core/dicnode/dic_node.h"
+#include "suggest/policyimpl/typing/scoring_params.h"
namespace latinime {
const TypingWeighting TypingWeighting::sInstance;
diff --git a/native/jni/src/suggest/policyimpl/typing/typing_weighting.h b/native/jni/src/suggest/policyimpl/typing/typing_weighting.h
index e8075f41a..52d54eb0f 100644
--- a/native/jni/src/suggest/policyimpl/typing/typing_weighting.h
+++ b/native/jni/src/suggest/policyimpl/typing/typing_weighting.h
@@ -18,9 +18,10 @@
#define LATINIME_TYPING_WEIGHTING_H
#include "defines.h"
-#include "dic_node_utils.h"
-#include "dic_traverse_session.h"
-#include "weighting.h"
+#include "suggest/core/dicnode/dic_node_utils.h"
+#include "suggest/core/policy/weighting.h"
+#include "suggest/core/session/dic_traverse_session.h"
+#include "suggest/policyimpl/typing/scoring_params.h"
namespace latinime {
diff --git a/native/jni/src/suggest/typing_suggest.h b/native/jni/src/suggest/typing_suggest.h
deleted file mode 100644
index 678037aa2..000000000
--- a/native/jni/src/suggest/typing_suggest.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#ifndef LATINIME_TYPING_SUGGEST_H
-#define LATINIME_TYPING_SUGGEST_H
-
-#include "defines.h"
-#include "suggest_interface.h"
-
-namespace latinime {
-
-class ProximityInfo;
-
-class TypingSuggest : public SuggestInterface {
- public:
- TypingSuggest() : mSuggestInterface(getTypingSuggestInstance()) {}
-
- virtual ~TypingSuggest();
-
- int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs,
- int *times, int *pointerIds, int *inputCodePoints, int inputSize, int commitPoint,
- int *outWords, int *frequencies, int *outputIndices, int *outputTypes) const {
- if (!mSuggestInterface) {
- return 0;
- }
- return mSuggestInterface->getSuggestions(pInfo, traverseSession, inputXs, inputYs, times,
- pointerIds, inputCodePoints, inputSize, commitPoint, outWords, frequencies,
- outputIndices, outputTypes);
- }
-
- static void setTypingSuggestFactoryMethod(SuggestInterface *(*factoryMethod)()) {
- sTypingSuggestFactoryMethod = factoryMethod;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TypingSuggest);
- static SuggestInterface *getTypingSuggestInstance() {
- if (!sTypingSuggestFactoryMethod) {
- return 0;
- }
- return sTypingSuggestFactoryMethod();
- }
-
- static SuggestInterface *(*sTypingSuggestFactoryMethod)();
- SuggestInterface *mSuggestInterface;
-};
-} // namespace latinime
-#endif // LATINIME_TYPING_SUGGEST_H