diff options
author | 2013-04-17 21:25:27 -0700 | |
---|---|---|
committer | 2013-04-17 21:25:27 -0700 | |
commit | 8acab80a8680956038b45912d3e00a1d6a5e3cdb (patch) | |
tree | 3c8587228fa91ea280e8d87675705a171d0164a1 /java/src/com/android/inputmethod/research/MainLogBuffer.java | |
parent | 0163591de1e71df966bfd7a2203dc1a30dc19477 (diff) | |
parent | 56f35a10cde1beeea51d99427992d832fa2de2bb (diff) | |
download | latinime-8acab80a8680956038b45912d3e00a1d6a5e3cdb.tar.gz latinime-8acab80a8680956038b45912d3e00a1d6a5e3cdb.tar.xz latinime-8acab80a8680956038b45912d3e00a1d6a5e3cdb.zip |
am 56f35a10: Merge "Fix bug in counting words between samples"
* commit '56f35a10cde1beeea51d99427992d832fa2de2bb':
Fix bug in counting words between samples
Diffstat (limited to 'java/src/com/android/inputmethod/research/MainLogBuffer.java')
-rw-r--r-- | java/src/com/android/inputmethod/research/MainLogBuffer.java | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/research/MainLogBuffer.java b/java/src/com/android/inputmethod/research/MainLogBuffer.java index 3303d2bdb..cd4c1db6e 100644 --- a/java/src/com/android/inputmethod/research/MainLogBuffer.java +++ b/java/src/com/android/inputmethod/research/MainLogBuffer.java @@ -25,7 +25,6 @@ import com.android.inputmethod.latin.define.ProductionFlag; import java.util.ArrayList; import java.util.LinkedList; -import java.util.Random; /** * MainLogBuffer is a FixedLogBuffer that tracks the state of LogUnits to make privacy guarantees. @@ -100,10 +99,6 @@ public abstract class MainLogBuffer extends FixedLogBuffer { return mSuggest.getMainDictionary(); } - public void resetWordCounter() { - mNumWordsUntilSafeToSample = mNumWordsBetweenNGrams; - } - public void setIsStopping() { mIsStopping = true; } @@ -201,7 +196,7 @@ public abstract class MainLogBuffer extends FixedLogBuffer { // Good n-gram at the front of the buffer. Publish it, disclosing details. publish(logUnits, true /* canIncludePrivateData */); shiftOutWords(N_GRAM_SIZE); - resetWordCounter(); + mNumWordsUntilSafeToSample = mNumWordsBetweenNGrams; } else { // No good n-gram at front, and buffer is full. Shift out the first word (or if there // is none, the existing logUnits). @@ -224,13 +219,13 @@ public abstract class MainLogBuffer extends FixedLogBuffer { final boolean canIncludePrivateData); @Override - protected void shiftOutWords(final int numWords) { - final int oldNumActualWords = getNumActualWords(); - super.shiftOutWords(numWords); - final int numWordsShifted = oldNumActualWords - getNumActualWords(); - mNumWordsUntilSafeToSample -= numWordsShifted; + protected int shiftOutWords(final int numWords) { + final int numWordContainingLogUnitsShiftedOut = super.shiftOutWords(numWords); + mNumWordsUntilSafeToSample = Math.max(0, mNumWordsUntilSafeToSample + - numWordContainingLogUnitsShiftedOut); if (DEBUG) { Log.d(TAG, "wordsUntilSafeToSample now at " + mNumWordsUntilSafeToSample); } + return numWordContainingLogUnitsShiftedOut; } } |