From 4ee953125af53d8b49e958e50f0002f002776d36 Mon Sep 17 00:00:00 2001 From: Satoshi Kataoka Date: Wed, 14 Aug 2013 14:46:49 +0900 Subject: [PATCH] Add a method to import one bigram and string utilities Bug: 9429906 Change-Id: I73bbf65985196d62470552c576bb076a7cb95008 --- .../PersonalizationDictionaryUpdateSession.java | 12 +++++++++++- .../android/inputmethod/latin/utils/StringUtils.java | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java index e9dbbc273..a755f90d5 100644 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java +++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java @@ -70,7 +70,17 @@ public abstract class PersonalizationDictionaryUpdateSession { 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 lmParams) { final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary(); if (dictionary == null) { diff --git a/java/src/com/android/inputmethod/latin/utils/StringUtils.java b/java/src/com/android/inputmethod/latin/utils/StringUtils.java index f88f2cca7..4ddd3c51d 100644 --- a/java/src/com/android/inputmethod/latin/utils/StringUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/StringUtils.java @@ -345,4 +345,14 @@ public final class StringUtils { // Otherwise, it doesn't look like an URL. 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; + } }