// TODO: Resolve the inconsistencies between the native auto correction algorithms and
 // this safety net
 public static boolean shouldBlockAutoCorrectionBySafetyNet(
     final String typedWord, final String suggestion) {
   // Safety net for auto correction.
   // Actually if we hit this safety net, it's a bug.
   // If user selected aggressive auto correction mode, there is no need to use the safety
   // net.
   // If the length of typed word is less than MINIMUM_SAFETY_NET_CHAR_LENGTH,
   // we should not use net because relatively edit distance can be big.
   final int typedWordLength = typedWord.length();
   if (typedWordLength < MINIMUM_SAFETY_NET_CHAR_LENGTH) {
     return false;
   }
   final int maxEditDistanceOfNativeDictionary = (typedWordLength / 2) + 1;
   final int distance = BinaryDictionaryUtils.editDistance(typedWord, suggestion);
   if (DBG) {
     Log.d(
         TAG,
         "Autocorrected edit distance = " + distance + ", " + maxEditDistanceOfNativeDictionary);
   }
   if (distance > maxEditDistanceOfNativeDictionary) {
     if (DBG) {
       Log.e(TAG, "Safety net: before = " + typedWord + ", after = " + suggestion);
       Log.e(
           TAG,
           "(Error) The edit distance of this correction exceeds limit. "
               + "Turning off auto-correction.");
     }
     return true;
   } else {
     return false;
   }
 }
 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;
 }
 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;
 }