[Rlog78a] Annotate logUnits with corrections

If the user makes a correction to a word, this is now explicitly indicated
in the logUnit.

Change-Id: I8638aadd7b8c8e32bbc9c4b020548d786513d887
main
Kurt Partridge 2013-01-11 14:17:17 -08:00
parent e6a9655a03
commit 345ef67627
3 changed files with 41 additions and 4 deletions

View File

@ -60,6 +60,7 @@ import java.util.Map;
private String mWord; private String mWord;
private boolean mMayContainDigit; private boolean mMayContainDigit;
private boolean mIsPartOfMegaword; private boolean mIsPartOfMegaword;
private boolean mContainsCorrection;
public LogUnit() { public LogUnit() {
mLogStatementList = new ArrayList<LogStatement>(); mLogStatementList = new ArrayList<LogStatement>();
@ -274,6 +275,14 @@ import java.util.Map;
return mMayContainDigit; return mMayContainDigit;
} }
public void setContainsCorrection() {
mContainsCorrection = true;
}
public boolean containsCorrection() {
return mContainsCorrection;
}
public boolean isEmpty() { public boolean isEmpty() {
return mLogStatementList.isEmpty(); return mLogStatementList.isEmpty();
} }
@ -301,6 +310,7 @@ import java.util.Map;
true /* isPartOfMegaword */); true /* isPartOfMegaword */);
newLogUnit.mWord = null; newLogUnit.mWord = null;
newLogUnit.mMayContainDigit = mMayContainDigit; newLogUnit.mMayContainDigit = mMayContainDigit;
newLogUnit.mContainsCorrection = mContainsCorrection;
// Purge the logStatements and associated data from this LogUnit. // Purge the logStatements and associated data from this LogUnit.
laterLogStatements.clear(); laterLogStatements.clear();
@ -320,6 +330,7 @@ import java.util.Map;
mTimeList.addAll(logUnit.mTimeList); mTimeList.addAll(logUnit.mTimeList);
mWord = null; mWord = null;
mMayContainDigit = mMayContainDigit || logUnit.mMayContainDigit; mMayContainDigit = mMayContainDigit || logUnit.mMayContainDigit;
mContainsCorrection = mContainsCorrection || logUnit.mContainsCorrection;
mIsPartOfMegaword = false; mIsPartOfMegaword = false;
} }
} }

View File

@ -720,6 +720,10 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
mCurrentLogUnit.setMayContainDigit(); mCurrentLogUnit.setMayContainDigit();
} }
private void setCurrentLogUnitContainsCorrection() {
mCurrentLogUnit.setContainsCorrection();
}
/* package for test */ void commitCurrentLogUnit() { /* package for test */ void commitCurrentLogUnit() {
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "commitCurrentLogUnit" + (mCurrentLogUnit.hasWord() ? Log.d(TAG, "commitCurrentLogUnit" + (mCurrentLogUnit.hasWord() ?
@ -850,7 +854,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
mCurrentLogUnit.setWord(word); mCurrentLogUnit.setWord(word);
final boolean isDictionaryWord = dictionary != null final boolean isDictionaryWord = dictionary != null
&& dictionary.isValidWord(word); && dictionary.isValidWord(word);
mStatistics.recordWordEntered(isDictionaryWord); mStatistics.recordWordEntered(isDictionaryWord, mCurrentLogUnit.containsCorrection());
} }
final LogUnit newLogUnit = mCurrentLogUnit.splitByTime(maxTime); final LogUnit newLogUnit = mCurrentLogUnit.splitByTime(maxTime);
enqueueCommitText(word, isBatchMode); enqueueCommitText(word, isBatchMode);
@ -1181,6 +1185,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
scrubDigitsFromString(replacedWord), index, scrubDigitsFromString(replacedWord), index,
suggestion == null ? null : scrubbedWord, Constants.SUGGESTION_STRIP_COORDINATE, suggestion == null ? null : scrubbedWord, Constants.SUGGESTION_STRIP_COORDINATE,
Constants.SUGGESTION_STRIP_COORDINATE); Constants.SUGGESTION_STRIP_COORDINATE);
researchLogger.setCurrentLogUnitContainsCorrection();
researchLogger.commitCurrentLogUnitAsWord(scrubbedWord, Long.MAX_VALUE, isBatchMode); researchLogger.commitCurrentLogUnitAsWord(scrubbedWord, Long.MAX_VALUE, isBatchMode);
researchLogger.mStatistics.recordManualSuggestion(SystemClock.uptimeMillis()); researchLogger.mStatistics.recordManualSuggestion(SystemClock.uptimeMillis());
} }
@ -1340,6 +1345,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
researchLogger.enqueueEvent(logUnit != null ? logUnit : researchLogger.mCurrentLogUnit, researchLogger.enqueueEvent(logUnit != null ? logUnit : researchLogger.mCurrentLogUnit,
LOGSTATEMENT_LATINIME_REVERTCOMMIT, committedWord, originallyTypedWord, LOGSTATEMENT_LATINIME_REVERTCOMMIT, committedWord, originallyTypedWord,
separatorString); separatorString);
if (logUnit != null) {
logUnit.setContainsCorrection();
}
researchLogger.mStatistics.recordRevertCommit(SystemClock.uptimeMillis()); researchLogger.mStatistics.recordRevertCommit(SystemClock.uptimeMillis());
researchLogger.commitCurrentLogUnitAsWord(originallyTypedWord, Long.MAX_VALUE, isBatchMode); researchLogger.commitCurrentLogUnitAsWord(originallyTypedWord, Long.MAX_VALUE, isBatchMode);
} }
@ -1500,6 +1508,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
final ResearchLogger researchLogger = getInstance(); final ResearchLogger researchLogger = getInstance();
final String scrubbedWord = scrubDigitsFromString(committedWord); final String scrubbedWord = scrubDigitsFromString(committedWord);
researchLogger.enqueueEvent(LOGSTATEMENT_COMMIT_PARTIAL_TEXT); researchLogger.enqueueEvent(LOGSTATEMENT_COMMIT_PARTIAL_TEXT);
researchLogger.mStatistics.recordAutoCorrection(SystemClock.uptimeMillis());
researchLogger.commitCurrentLogUnitAsWord(scrubbedWord, lastTimestampOfWordData, researchLogger.commitCurrentLogUnitAsWord(scrubbedWord, lastTimestampOfWordData,
isBatchMode); isBatchMode);
} }
@ -1740,7 +1749,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
"averageTimeDuringRepeatedDelete", "averageTimeAfterDelete", "averageTimeDuringRepeatedDelete", "averageTimeAfterDelete",
"dictionaryWordCount", "splitWordsCount", "gestureInputCount", "dictionaryWordCount", "splitWordsCount", "gestureInputCount",
"gestureCharsCount", "gesturesDeletedCount", "manualSuggestionsCount", "gestureCharsCount", "gesturesDeletedCount", "manualSuggestionsCount",
"revertCommitsCount"); "revertCommitsCount", "correctedWordsCount", "autoCorrectionsCount");
private static void logStatistics() { private static void logStatistics() {
final ResearchLogger researchLogger = getInstance(); final ResearchLogger researchLogger = getInstance();
final Statistics statistics = researchLogger.mStatistics; final Statistics statistics = researchLogger.mStatistics;
@ -1754,6 +1763,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
statistics.mDictionaryWordCount, statistics.mSplitWordsCount, statistics.mDictionaryWordCount, statistics.mSplitWordsCount,
statistics.mGesturesInputCount, statistics.mGesturesCharsCount, statistics.mGesturesInputCount, statistics.mGesturesCharsCount,
statistics.mGesturesDeletedCount, statistics.mManualSuggestionsCount, statistics.mGesturesDeletedCount, statistics.mManualSuggestionsCount,
statistics.mRevertCommitsCount); statistics.mRevertCommitsCount, statistics.mCorrectedWordsCount,
statistics.mAutoCorrectionsCount);
} }
} }

View File

@ -25,6 +25,7 @@ public class Statistics {
private static final String TAG = Statistics.class.getSimpleName(); private static final String TAG = Statistics.class.getSimpleName();
private static final boolean DEBUG = false && ProductionFlag.IS_EXPERIMENTAL_DEBUG; private static final boolean DEBUG = false && ProductionFlag.IS_EXPERIMENTAL_DEBUG;
// TODO: Cleanup comments to only including those giving meaningful information.
// Number of characters entered during a typing session // Number of characters entered during a typing session
int mCharCount; int mCharCount;
// Number of letter characters entered during a typing session // Number of letter characters entered during a typing session
@ -41,6 +42,8 @@ public class Statistics {
int mDictionaryWordCount; int mDictionaryWordCount;
// Number of words split and spaces automatically entered. // Number of words split and spaces automatically entered.
int mSplitWordsCount; int mSplitWordsCount;
// Number of words entered during a session.
int mCorrectedWordsCount;
// Number of gestures that were input. // Number of gestures that were input.
int mGesturesInputCount; int mGesturesInputCount;
// Number of gestures that were deleted. // Number of gestures that were deleted.
@ -49,6 +52,8 @@ public class Statistics {
int mGesturesCharsCount; int mGesturesCharsCount;
// Number of manual suggestions chosen. // Number of manual suggestions chosen.
int mManualSuggestionsCount; int mManualSuggestionsCount;
// Number of times that autocorrection was invoked.
int mAutoCorrectionsCount;
// Number of times a commit was reverted in this session. // Number of times a commit was reverted in this session.
int mRevertCommitsCount; int mRevertCommitsCount;
// Whether the text field was empty upon editing // Whether the text field was empty upon editing
@ -113,10 +118,12 @@ public class Statistics {
mWordCount = 0; mWordCount = 0;
mDictionaryWordCount = 0; mDictionaryWordCount = 0;
mSplitWordsCount = 0; mSplitWordsCount = 0;
mCorrectedWordsCount = 0;
mGesturesInputCount = 0; mGesturesInputCount = 0;
mGesturesDeletedCount = 0; mGesturesDeletedCount = 0;
mManualSuggestionsCount = 0; mManualSuggestionsCount = 0;
mRevertCommitsCount = 0; mRevertCommitsCount = 0;
mAutoCorrectionsCount = 0;
mIsEmptyUponStarting = true; mIsEmptyUponStarting = true;
mIsEmptinessStateKnown = false; mIsEmptinessStateKnown = false;
mKeyCounter.reset(); mKeyCounter.reset();
@ -152,11 +159,15 @@ public class Statistics {
} }
} }
public void recordWordEntered(final boolean isDictionaryWord) { public void recordWordEntered(final boolean isDictionaryWord,
final boolean containsCorrection) {
mWordCount++; mWordCount++;
if (isDictionaryWord) { if (isDictionaryWord) {
mDictionaryWordCount++; mDictionaryWordCount++;
} }
if (containsCorrection) {
mCorrectedWordsCount++;
}
} }
public void recordSplitWords() { public void recordSplitWords() {
@ -184,6 +195,11 @@ public class Statistics {
recordUserAction(time, false /* isDeletion */); recordUserAction(time, false /* isDeletion */);
} }
public void recordAutoCorrection(final long time) {
mAutoCorrectionsCount++;
recordUserAction(time, false /* isDeletion */);
}
public void recordRevertCommit(final long time) { public void recordRevertCommit(final long time) {
mRevertCommitsCount++; mRevertCommitsCount++;
recordUserAction(time, true /* isDeletion */); recordUserAction(time, true /* isDeletion */);