aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/research/MainLogBuffer.java
diff options
context:
space:
mode:
authorKurt Partridge <kep@google.com>2013-01-08 07:40:56 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-01-08 07:40:57 -0800
commitb7fb16e8ccbdd867221109e48a3a5b804f87b80d (patch)
tree3869fa0698e0326045d2eae470a36b06e51d46a8 /java/src/com/android/inputmethod/research/MainLogBuffer.java
parent398b79eea1945ebc9632490afd29ecff551bf929 (diff)
parentf77dd424b077a7f8ff547c09cb94d0dc7f0daed7 (diff)
downloadlatinime-b7fb16e8ccbdd867221109e48a3a5b804f87b80d.tar.gz
latinime-b7fb16e8ccbdd867221109e48a3a5b804f87b80d.tar.xz
latinime-b7fb16e8ccbdd867221109e48a3a5b804f87b80d.zip
Merge "[Rlog27] Refactor LogBuffer"
Diffstat (limited to 'java/src/com/android/inputmethod/research/MainLogBuffer.java')
-rw-r--r--java/src/com/android/inputmethod/research/MainLogBuffer.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/research/MainLogBuffer.java b/java/src/com/android/inputmethod/research/MainLogBuffer.java
index 0185e5fc0..bec21d7e0 100644
--- a/java/src/com/android/inputmethod/research/MainLogBuffer.java
+++ b/java/src/com/android/inputmethod/research/MainLogBuffer.java
@@ -22,15 +22,24 @@ import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.Suggest;
import com.android.inputmethod.latin.define.ProductionFlag;
+import java.util.LinkedList;
import java.util.Random;
-public class MainLogBuffer extends LogBuffer {
+/**
+ * Provide a log buffer of fixed length that enforces privacy restrictions.
+ *
+ * The privacy restrictions include making sure that no numbers are logged, that all logged words
+ * are in the dictionary, and that words are recorded infrequently enough that the user's meaning
+ * cannot be easily determined.
+ */
+public class MainLogBuffer extends FixedLogBuffer {
private static final String TAG = MainLogBuffer.class.getSimpleName();
private static final boolean DEBUG = false && ProductionFlag.IS_EXPERIMENTAL_DEBUG;
// The size of the n-grams logged. E.g. N_GRAM_SIZE = 2 means to sample bigrams.
private static final int N_GRAM_SIZE = 2;
- // The number of words between n-grams to omit from the log.
+ // The number of words between n-grams to omit from the log. If debugging, record 50% of all
+ // words. Otherwise, only record 10%.
private static final int DEFAULT_NUMBER_OF_WORDS_BETWEEN_SAMPLES =
ProductionFlag.IS_EXPERIMENTAL_DEBUG ? 2 : 18;
@@ -56,7 +65,7 @@ public class MainLogBuffer extends LogBuffer {
mWordsUntilSafeToSample = random.nextInt(mMinWordPeriod);
}
- public void setSuggest(Suggest suggest) {
+ public void setSuggest(final Suggest suggest) {
mSuggest = suggest;
}
@@ -108,9 +117,10 @@ public class MainLogBuffer extends LogBuffer {
}
// Check each word in the buffer. If any word poses a privacy threat, we cannot upload the
// complete buffer contents in detail.
- final int length = mLogUnits.size();
+ final LinkedList<LogUnit> logUnits = getLogUnits();
+ final int length = logUnits.size();
for (int i = 0; i < length; i++) {
- final LogUnit logUnit = mLogUnits.get(i);
+ final LogUnit logUnit = logUnits.get(i);
final String word = logUnit.getWord();
if (word == null) {
// Digits outside words are a privacy threat.
@@ -133,7 +143,7 @@ public class MainLogBuffer extends LogBuffer {
}
@Override
- protected void onShiftOut(LogUnit logUnit) {
+ protected void onShiftOut(final LogUnit logUnit) {
if (mResearchLog != null) {
mResearchLog.publish(logUnit, false /* isIncludingPrivateData */);
}