am 2baa4b07: [Rlog83] Fix missing uses of hasWord() abstraction
# Via Kurt Partridge * commit '2baa4b0701c6e02aa25b03881c8863b2d3856282': [Rlog83] Fix missing uses of hasWord() abstractionmain
commit
10e1176102
|
@ -61,7 +61,7 @@ public class FixedLogBuffer extends LogBuffer {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void shiftIn(final LogUnit newLogUnit) {
|
public void shiftIn(final LogUnit newLogUnit) {
|
||||||
if (newLogUnit.getWord() == null) {
|
if (!newLogUnit.hasWord()) {
|
||||||
// This LogUnit isn't a word, so it doesn't count toward the word-limit.
|
// This LogUnit isn't a word, so it doesn't count toward the word-limit.
|
||||||
super.shiftIn(newLogUnit);
|
super.shiftIn(newLogUnit);
|
||||||
return;
|
return;
|
||||||
|
@ -153,8 +153,7 @@ public class FixedLogBuffer extends LogBuffer {
|
||||||
for (int i = 0; i < length && n > 0; i++) {
|
for (int i = 0; i < length && n > 0; i++) {
|
||||||
final LogUnit logUnit = logUnits.get(i);
|
final LogUnit logUnit = logUnits.get(i);
|
||||||
list.add(logUnit);
|
list.add(logUnit);
|
||||||
final String word = logUnit.getWord();
|
if (logUnit.hasWord()) {
|
||||||
if (word != null) {
|
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,7 +286,7 @@ import java.util.Map;
|
||||||
* string.
|
* string.
|
||||||
*/
|
*/
|
||||||
public void setWord(final String word) {
|
public void setWord(final String word) {
|
||||||
if (mWord != null) {
|
if (hasWord()) {
|
||||||
// The word was already set once, and it is now being changed. See if the new word
|
// The word was already set once, and it is now being changed. See if the new word
|
||||||
// is close to the old word. If so, then the change is probably a typo correction.
|
// is close to the old word. If so, then the change is probably a typo correction.
|
||||||
// If not, the user may have decided to enter a different word, so flag it.
|
// If not, the user may have decided to enter a different word, so flag it.
|
||||||
|
@ -310,7 +310,7 @@ import java.util.Map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasWord() {
|
public boolean hasWord() {
|
||||||
return mWord != null;
|
return mWord != null && !TextUtils.isEmpty(mWord.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMayContainDigit() {
|
public void setMayContainDigit() {
|
||||||
|
|
|
@ -117,20 +117,19 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
|
||||||
if (IS_LOGGING_EVERYTHING) {
|
if (IS_LOGGING_EVERYTHING) {
|
||||||
if (mIsStopping) {
|
if (mIsStopping) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
// Only check that it is the right length. If not, wait for later words to make
|
|
||||||
// complete n-grams.
|
|
||||||
int numWordsInLogUnitList = 0;
|
|
||||||
final int length = logUnits.size();
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
final LogUnit logUnit = logUnits.get(i);
|
|
||||||
final String word = logUnit.getWord();
|
|
||||||
if (word != null) {
|
|
||||||
numWordsInLogUnitList++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return numWordsInLogUnitList >= minNGramSize;
|
|
||||||
}
|
}
|
||||||
|
// Only check that it is the right length. If not, wait for later words to make
|
||||||
|
// complete n-grams.
|
||||||
|
int numWordsInLogUnitList = 0;
|
||||||
|
final int length = logUnits.size();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
final LogUnit logUnit = logUnits.get(i);
|
||||||
|
final String word = logUnit.getWord();
|
||||||
|
if (word != null) {
|
||||||
|
numWordsInLogUnitList++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return numWordsInLogUnitList >= minNGramSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that we are not sampling too frequently. Having sampled recently might disclose
|
// Check that we are not sampling too frequently. Having sampled recently might disclose
|
||||||
|
@ -157,14 +156,14 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
|
||||||
final int length = logUnits.size();
|
final int length = logUnits.size();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
final LogUnit logUnit = logUnits.get(i);
|
final LogUnit logUnit = logUnits.get(i);
|
||||||
final String word = logUnit.getWord();
|
if (!logUnit.hasWord()) {
|
||||||
if (word == null) {
|
|
||||||
// Digits outside words are a privacy threat.
|
// Digits outside words are a privacy threat.
|
||||||
if (logUnit.mayContainDigit()) {
|
if (logUnit.mayContainDigit()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
numWordsInLogUnitList++;
|
numWordsInLogUnitList++;
|
||||||
|
final String word = logUnit.getWord();
|
||||||
// Words not in the dictionary are a privacy threat.
|
// Words not in the dictionary are a privacy threat.
|
||||||
if (ResearchLogger.hasLetters(word) && !(dictionary.isValidWord(word))) {
|
if (ResearchLogger.hasLetters(word) && !(dictionary.isValidWord(word))) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
|
Loading…
Reference in New Issue