OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C) 2012 The Android Open Source Project |
| 3 * |
| 4 * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 * you may not use this file except in compliance with the License. |
| 6 * You may obtain a copy of the License at |
| 7 * |
| 8 * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 * |
| 10 * Unless required by applicable law or agreed to in writing, software |
| 11 * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 * See the License for the specific language governing permissions and |
| 14 * limitations under the License. |
| 15 */ |
| 16 |
| 17 #ifndef LATINIME_SUGGEST_IMPL_H |
| 18 #define LATINIME_SUGGEST_IMPL_H |
| 19 |
| 20 #include "third_party/android_prediction/defines.h" |
| 21 #include "third_party/android_prediction/suggest/core/suggest_interface.h" |
| 22 #include "third_party/android_prediction/suggest/core/policy/suggest_policy.h" |
| 23 |
| 24 namespace latinime { |
| 25 |
| 26 // Naming convention |
| 27 // - Distance: "Weighted" edit distance -- used both for spatial and language. |
| 28 // - Compound Distance: Spatial Distance + Language Distance -- used for pruning
and scoring |
| 29 // - Cost: delta/diff for Distance -- used both for spatial and language |
| 30 // - Length: "Non-weighted" -- used only for spatial |
| 31 // - Probability: "Non-weighted" -- used only for language |
| 32 // - Score: Final calibrated score based on the compound distance, which is sent
to java as the |
| 33 // priority of a suggested word |
| 34 |
| 35 class DicNode; |
| 36 class DicTraverseSession; |
| 37 class ProximityInfo; |
| 38 class Scoring; |
| 39 class SuggestionResults; |
| 40 class Traversal; |
| 41 class Weighting; |
| 42 |
| 43 class Suggest : public SuggestInterface { |
| 44 public: |
| 45 AK_FORCE_INLINE Suggest(const SuggestPolicy *const suggestPolicy) |
| 46 : TRAVERSAL(suggestPolicy ? suggestPolicy->getTraversal() : nullptr)
, |
| 47 SCORING(suggestPolicy ? suggestPolicy->getScoring() : nullptr), |
| 48 WEIGHTING(suggestPolicy ? suggestPolicy->getWeighting() : nullptr)
{} |
| 49 AK_FORCE_INLINE virtual ~Suggest() {} |
| 50 void getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputX
s, int *inputYs, |
| 51 int *times, int *pointerIds, int *inputCodePoints, int inputSize, |
| 52 const float languageWeight, SuggestionResults *const outSuggestionRe
sults) const; |
| 53 |
| 54 private: |
| 55 DISALLOW_IMPLICIT_CONSTRUCTORS(Suggest); |
| 56 void createNextWordDicNode(DicTraverseSession *traverseSession, DicNode *dic
Node, |
| 57 const bool spaceSubstitution) const; |
| 58 void initializeSearch(DicTraverseSession *traverseSession) const; |
| 59 void expandCurrentDicNodes(DicTraverseSession *traverseSession) const; |
| 60 void processTerminalDicNode(DicTraverseSession *traverseSession, DicNode *di
cNode) const; |
| 61 void processExpandedDicNode(DicTraverseSession *traverseSession, DicNode *di
cNode) const; |
| 62 void weightChildNode(DicTraverseSession *traverseSession, DicNode *dicNode)
const; |
| 63 void processDicNodeAsOmission(DicTraverseSession *traverseSession, DicNode *
dicNode) const; |
| 64 void processDicNodeAsDigraph(DicTraverseSession *traverseSession, DicNode *d
icNode) const; |
| 65 void processDicNodeAsTransposition(DicTraverseSession *traverseSession, |
| 66 DicNode *dicNode) const; |
| 67 void processDicNodeAsInsertion(DicTraverseSession *traverseSession, DicNode
*dicNode) const; |
| 68 void processDicNodeAsAdditionalProximityChar(DicTraverseSession *traverseSes
sion, |
| 69 DicNode *dicNode, DicNode *childDicNode) const; |
| 70 void processDicNodeAsSubstitution(DicTraverseSession *traverseSession, DicNo
de *dicNode, |
| 71 DicNode *childDicNode) const; |
| 72 void processDicNodeAsMatch(DicTraverseSession *traverseSession, |
| 73 DicNode *childDicNode) const; |
| 74 |
| 75 static const int MIN_CONTINUOUS_SUGGESTION_INPUT_SIZE; |
| 76 |
| 77 const Traversal *const TRAVERSAL; |
| 78 const Scoring *const SCORING; |
| 79 const Weighting *const WEIGHTING; |
| 80 }; |
| 81 } // namespace latinime |
| 82 #endif // LATINIME_SUGGEST_IMPL_H |
OLD | NEW |