aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2014-10-06 07:03:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-10-06 07:03:55 +0000
commit1616d6d44098ce9fd8c65383af21c88799927b17 (patch)
tree21528f2626008cde0e6acc21e6dea6091cbd981c /java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
parentadd93b1190eef80e495a518da20d4470b0bf07f4 (diff)
parent9290d0a4eba454b9b1501830a4e470005cc85332 (diff)
downloadlatinime-1616d6d44098ce9fd8c65383af21c88799927b17.tar.gz
latinime-1616d6d44098ce9fd8c65383af21c88799927b17.tar.xz
latinime-1616d6d44098ce9fd8c65383af21c88799927b17.zip
Merge "Make UserHistoryDictionary use updateEntriesForWordWithNgramContext()"
Diffstat (limited to 'java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java')
-rw-r--r--java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java31
1 files changed, 2 insertions, 29 deletions
diff --git a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
index d61684698..59761547d 100644
--- a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
@@ -65,34 +65,7 @@ public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBas
if (word.length() > Constants.DICTIONARY_MAX_WORD_LENGTH) {
return;
}
- final int frequency = isValid ?
- FREQUENCY_FOR_WORDS_IN_DICTS : FREQUENCY_FOR_WORDS_NOT_IN_DICTS;
- userHistoryDictionary.addUnigramEntryWithCheckingDistracter(word, frequency,
- null /* shortcutTarget */, 0 /* shortcutFreq */, false /* isNotAWord */,
- false /* isBlacklisted */, timestamp, distracterFilter);
-
- final boolean isBeginningOfSentenceContext = ngramContext.isBeginningOfSentenceContext();
- final NgramContext ngramContextToBeSaved =
- ngramContext.getTrimmedNgramContext(SUPPORTED_NGRAM - 1);
- for (int i = 0; i < ngramContextToBeSaved.getPrevWordCount(); i++) {
- final CharSequence prevWord = ngramContextToBeSaved.getNthPrevWord(1 /* n */);
- if (prevWord == null || (prevWord.length() > Constants.DICTIONARY_MAX_WORD_LENGTH)) {
- return;
- }
- // Do not insert a word as a bigram of itself
- if (i == 0 && TextUtils.equals(word, prevWord)) {
- return;
- }
- if (isBeginningOfSentenceContext) {
- // Beginning-of-Sentence n-gram entry is added as an n-gram entry of an OOV word.
- userHistoryDictionary.addNgramEntry(
- ngramContextToBeSaved.getTrimmedNgramContext(i + 1), word,
- FREQUENCY_FOR_WORDS_NOT_IN_DICTS, timestamp);
- } else {
- userHistoryDictionary.addNgramEntry(
- ngramContextToBeSaved.getTrimmedNgramContext(i + 1), word, frequency,
- timestamp);
- }
- }
+ userHistoryDictionary.updateEntriesForWordWithCheckingDistracter(ngramContext, word,
+ isValid, 1 /* count */, timestamp, distracterFilter);
}
}