Add debugging info for Latin IME.
Add frequency of candidates in the candidates view when the debug mode is active. Bug: 3312867 Change-Id: Ie911f14ef11b2fa02af8f3a74302129f16ed0604main
parent
d5fb0913a9
commit
8553b5ec31
|
@ -54,7 +54,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan();
|
private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan();
|
||||||
private static final int MAX_SUGGESTIONS = 16;
|
private static final int MAX_SUGGESTIONS = 16;
|
||||||
|
|
||||||
private static boolean DBG = LatinImeLogger.sDBG;
|
private static final boolean DBG = LatinImeLogger.sDBG;
|
||||||
|
|
||||||
private final ArrayList<View> mWords = new ArrayList<View>();
|
private final ArrayList<View> mWords = new ArrayList<View>();
|
||||||
private final boolean mConfigCandidateHighlightFontColorEnabled;
|
private final boolean mConfigCandidateHighlightFontColorEnabled;
|
||||||
|
@ -226,10 +226,14 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
}
|
}
|
||||||
final String debugString = info.getDebugString();
|
final String debugString = info.getDebugString();
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
if (!TextUtils.isEmpty(debugString)) {
|
if (TextUtils.isEmpty(debugString)) {
|
||||||
|
dv.setVisibility(GONE);
|
||||||
|
} else {
|
||||||
dv.setText(debugString);
|
dv.setText(debugString);
|
||||||
dv.setVisibility(VISIBLE);
|
dv.setVisibility(VISIBLE);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
dv.setVisibility(GONE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dv.setVisibility(GONE);
|
dv.setVisibility(GONE);
|
||||||
|
@ -249,8 +253,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
final TextView tv = (TextView)mWords.get(1).findViewById(R.id.candidate_word);
|
final TextView tv = (TextView)mWords.get(1).findViewById(R.id.candidate_word);
|
||||||
final Spannable word = new SpannableString(autoCorrectedWord);
|
final Spannable word = new SpannableString(autoCorrectedWord);
|
||||||
final int wordLength = word.length();
|
final int wordLength = word.length();
|
||||||
word.setSpan(mInvertedBackgroundColorSpan, 0, wordLength, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
word.setSpan(mInvertedBackgroundColorSpan, 0, wordLength,
|
||||||
word.setSpan(mInvertedForegroundColorSpan, 0, wordLength, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
word.setSpan(mInvertedForegroundColorSpan, 0, wordLength,
|
||||||
|
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
tv.setText(word);
|
tv.setText(word);
|
||||||
mShowingAutoCorrectionInverted = true;
|
mShowingAutoCorrectionInverted = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
|
|
||||||
static final int LARGE_DICTIONARY_THRESHOLD = 200 * 1000;
|
static final int LARGE_DICTIONARY_THRESHOLD = 200 * 1000;
|
||||||
|
|
||||||
private static boolean DBG = LatinImeLogger.sDBG;
|
private static final boolean DBG = LatinImeLogger.sDBG;
|
||||||
|
|
||||||
private BinaryDictionary mMainDict;
|
private BinaryDictionary mMainDict;
|
||||||
|
|
||||||
|
@ -224,6 +224,7 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
mLowerOriginalWord = "";
|
mLowerOriginalWord = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double normalizedScore = Integer.MIN_VALUE;
|
||||||
if (wordComposer.size() == 1 && (mCorrectionMode == CORRECTION_FULL_BIGRAM
|
if (wordComposer.size() == 1 && (mCorrectionMode == CORRECTION_FULL_BIGRAM
|
||||||
|| mCorrectionMode == CORRECTION_BASIC)) {
|
|| mCorrectionMode == CORRECTION_BASIC)) {
|
||||||
// At first character typed, search only the bigrams
|
// At first character typed, search only the bigrams
|
||||||
|
@ -290,9 +291,9 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
&& mSuggestions.size() > 0 && mPriorities.length > 0) {
|
&& mSuggestions.size() > 0 && mPriorities.length > 0) {
|
||||||
// TODO: when the normalized score of the first suggestion is nearly equals to
|
// TODO: when the normalized score of the first suggestion is nearly equals to
|
||||||
// the normalized score of the second suggestion, behave less aggressive.
|
// the normalized score of the second suggestion, behave less aggressive.
|
||||||
final double normalizedScore = Utils.calcNormalizedScore(
|
normalizedScore = Utils.calcNormalizedScore(
|
||||||
typedWord, mSuggestions.get(0), mPriorities[0]);
|
typedWord, mSuggestions.get(0), mPriorities[0]);
|
||||||
if (LatinImeLogger.sDBG) {
|
if (DBG) {
|
||||||
Log.d(TAG, "Normalized " + typedWord + "," + mSuggestions.get(0) + ","
|
Log.d(TAG, "Normalized " + typedWord + "," + mSuggestions.get(0) + ","
|
||||||
+ mPriorities[0] + ", " + normalizedScore
|
+ mPriorities[0] + ", " + normalizedScore
|
||||||
+ "(" + mAutoCorrectionThreshold + ")");
|
+ "(" + mAutoCorrectionThreshold + ")");
|
||||||
|
@ -354,7 +355,30 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
removeDupes();
|
removeDupes();
|
||||||
return new SuggestedWords.Builder().addWords(mSuggestions, null);
|
if (DBG) {
|
||||||
|
ArrayList<SuggestedWords.SuggestedWordInfo> frequencyInfoList =
|
||||||
|
new ArrayList<SuggestedWords.SuggestedWordInfo>();
|
||||||
|
frequencyInfoList.add(new SuggestedWords.SuggestedWordInfo("+", false));
|
||||||
|
final int priorityLength = mPriorities.length;
|
||||||
|
for (int i = 0; i < priorityLength; ++i) {
|
||||||
|
if (normalizedScore > 0) {
|
||||||
|
final String priorityThreshold = Integer.toString(mPriorities[i]) + " (" +
|
||||||
|
normalizedScore + ")";
|
||||||
|
frequencyInfoList.add(
|
||||||
|
new SuggestedWords.SuggestedWordInfo(priorityThreshold, false));
|
||||||
|
normalizedScore = 0.0;
|
||||||
|
} else {
|
||||||
|
final String priority = Integer.toString(mPriorities[i]);
|
||||||
|
frequencyInfoList.add(new SuggestedWords.SuggestedWordInfo(priority, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = priorityLength; i < mSuggestions.size(); ++i) {
|
||||||
|
frequencyInfoList.add(new SuggestedWords.SuggestedWordInfo("--", false));
|
||||||
|
}
|
||||||
|
return new SuggestedWords.Builder().addWords(mSuggestions, frequencyInfoList);
|
||||||
|
} else {
|
||||||
|
return new SuggestedWords.Builder().addWords(mSuggestions, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getNextLettersFrequencies() {
|
public int[] getNextLettersFrequencies() {
|
||||||
|
|
Loading…
Reference in New Issue