Skip to content
Snippets Groups Projects
Commit 7c996475 authored by Kurt Partridge's avatar Kurt Partridge Committed by Android (Google) Code Review
Browse files

Merge "[TestPrep3] Add helper method to retrive dictionary"

parents c8a1ec6e 19e05359
No related branches found
No related tags found
No related merge requests found
...@@ -93,6 +93,11 @@ public abstract class MainLogBuffer extends FixedLogBuffer { ...@@ -93,6 +93,11 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
mSuggest = suggest; mSuggest = suggest;
} }
private Dictionary getDictionary() {
if (mSuggest == null || !mSuggest.hasMainDictionary()) return null;
return mSuggest.getMainDictionary();
}
public void resetWordCounter() { public void resetWordCounter() {
mNumWordsUntilSafeToSample = mNumWordsBetweenNGrams; mNumWordsUntilSafeToSample = mNumWordsBetweenNGrams;
} }
...@@ -137,16 +142,13 @@ public abstract class MainLogBuffer extends FixedLogBuffer { ...@@ -137,16 +142,13 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
if (mNumWordsUntilSafeToSample > 0) { if (mNumWordsUntilSafeToSample > 0) {
return false; return false;
} }
if (mSuggest == null || !mSuggest.hasMainDictionary()) {
// Main dictionary is unavailable. Since we cannot check it, we cannot tell if a
// word is out-of-vocabulary or not. Therefore, we must judge the entire buffer
// contents to potentially pose a privacy risk.
return false;
}
// Reload the dictionary in case it has changed (e.g., because the user has changed // Reload the dictionary in case it has changed (e.g., because the user has changed
// languages). // languages).
final Dictionary dictionary = mSuggest.getMainDictionary(); final Dictionary dictionary = getDictionary();
if (dictionary == null) { if (dictionary == null) {
// Main dictionary is unavailable. Since we cannot check it, we cannot tell if a
// word is out-of-vocabulary or not. Therefore, we must judge the entire buffer
// contents to potentially pose a privacy risk.
return false; return false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment