private static boolean suggestionExceedsDistracterThreshold(
     final SuggestedWordInfo suggestion,
     final String consideredWord,
     final float distracterThreshold) {
   if (suggestion == null) {
     return false;
   }
   final int suggestionScore = suggestion.mScore;
   final float normalizedScore =
       BinaryDictionaryUtils.calcNormalizedScore(
           consideredWord, suggestion.mWord, suggestionScore);
   if (DEBUG) {
     Log.d(TAG, "normalizedScore: " + normalizedScore);
     Log.d(TAG, "distracterThreshold: " + distracterThreshold);
   }
   if (normalizedScore > distracterThreshold) {
     return true;
   }
   return false;
 }
コード例 #2
0
 public static boolean suggestionExceedsAutoCorrectionThreshold(
     final SuggestedWordInfo suggestion,
     final String consideredWord,
     final float autoCorrectionThreshold) {
   if (null != suggestion) {
     // Shortlist a whitelisted word
     if (suggestion.isKindOf(SuggestedWordInfo.KIND_WHITELIST)) {
       return true;
     }
     final int autoCorrectionSuggestionScore = suggestion.mScore;
     // TODO: when the normalized score of the first suggestion is nearly equals to
     //       the normalized score of the second suggestion, behave less aggressive.
     final float normalizedScore =
         BinaryDictionaryUtils.calcNormalizedScore(
             consideredWord, suggestion.mWord, autoCorrectionSuggestionScore);
     if (DBG) {
       Log.d(
           TAG,
           "Normalized "
               + consideredWord
               + ","
               + suggestion
               + ","
               + autoCorrectionSuggestionScore
               + ", "
               + normalizedScore
               + "("
               + autoCorrectionThreshold
               + ")");
     }
     if (normalizedScore >= autoCorrectionThreshold) {
       if (DBG) {
         Log.d(TAG, "Auto corrected by S-threshold.");
       }
       return !shouldBlockAutoCorrectionBySafetyNet(consideredWord, suggestion.mWord);
     }
   }
   return false;
 }