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 #include "suggest/policyimpl/typing/typing_weighting.h" 18 19 #include "suggest/core/dicnode/dic_node.h" 20 #include "suggest/policyimpl/typing/scoring_params.h" 21 22 namespace latinime { 23 24 const TypingWeighting TypingWeighting::sInstance; 25 26 ErrorType TypingWeighting::getErrorType(const CorrectionType correctionType, 27 const DicTraverseSession *const traverseSession, const DicNode *const parentDicNode, 28 const DicNode *const dicNode) const { 29 switch (correctionType) { 30 case CT_MATCH: 31 if (isProximityDicNode(traverseSession, dicNode)) { 32 return ET_PROXIMITY_CORRECTION; 33 } else { 34 return ET_NOT_AN_ERROR; 35 } 36 case CT_ADDITIONAL_PROXIMITY: 37 return ET_PROXIMITY_CORRECTION; 38 case CT_OMISSION: 39 if (parentDicNode->canBeIntentionalOmission()) { 40 return ET_INTENTIONAL_OMISSION; 41 } else { 42 return ET_EDIT_CORRECTION; 43 } 44 break; 45 case CT_SUBSTITUTION: 46 case CT_INSERTION: 47 case CT_TERMINAL_INSERTION: 48 case CT_TRANSPOSITION: 49 return ET_EDIT_CORRECTION; 50 case CT_NEW_WORD_SPACE_OMISSION: 51 case CT_NEW_WORD_SPACE_SUBSTITUTION: 52 return ET_NEW_WORD; 53 case CT_TERMINAL: 54 return ET_NOT_AN_ERROR; 55 case CT_COMPLETION: 56 return ET_COMPLETION; 57 default: 58 return ET_NOT_AN_ERROR; 59 } 60 } 61 } // namespace latinime 62