diff options
author | 2013-04-18 04:23:28 +0000 | |
---|---|---|
committer | 2013-04-18 04:23:29 +0000 | |
commit | 56f35a10cde1beeea51d99427992d832fa2de2bb (patch) | |
tree | d95bf0b498a13b8b62f621c5897ef187b5f08def /java/src/com/android/inputmethod/research/MainLogBuffer.java | |
parent | 550824c7cfe15cf988f8baab64c3482d1c7906fa (diff) | |
parent | bf62dc9460408dc37324c03735ab13c2cdf45396 (diff) | |
download | latinime-56f35a10cde1beeea51d99427992d832fa2de2bb.tar.gz latinime-56f35a10cde1beeea51d99427992d832fa2de2bb.tar.xz latinime-56f35a10cde1beeea51d99427992d832fa2de2bb.zip |
Merge "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; } } |