Add a method to import one bigram and string utilities
Bug: 9429906 Change-Id: I73bbf65985196d62470552c576bb076a7cb95008main
parent
5fd8b7ebd5
commit
4ee953125a
|
@ -70,7 +70,17 @@ public abstract class PersonalizationDictionaryUpdateSession {
|
||||||
unsetPredictionDictionary();
|
unsetPredictionDictionary();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToPersonalizationDictionary(
|
public void addBigramToPersonalizationDictionary(String word0, String word1, boolean isValid,
|
||||||
|
int frequency) {
|
||||||
|
final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary();
|
||||||
|
if (dictionary == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dictionary.addToPersonalizationPredictionDictionary(word0, word1, isValid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bulk import
|
||||||
|
public void addBigramsToPersonalizationDictionary(
|
||||||
final ArrayList<PersonalizationLanguageModelParam> lmParams) {
|
final ArrayList<PersonalizationLanguageModelParam> lmParams) {
|
||||||
final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary();
|
final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary();
|
||||||
if (dictionary == null) {
|
if (dictionary == null) {
|
||||||
|
|
|
@ -345,4 +345,14 @@ public final class StringUtils {
|
||||||
// Otherwise, it doesn't look like an URL.
|
// Otherwise, it doesn't look like an URL.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isEmptyStringOrWhiteSpaces(String s) {
|
||||||
|
final int N = codePointCount(s);
|
||||||
|
for (int i = 0; i < N; ++i) {
|
||||||
|
if (!Character.isWhitespace(s.codePointAt(i))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue