aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
diff options
context:
space:
mode:
authorKen Wakasa <kwakasa@google.com>2014-05-20 14:00:45 +0000
committerKen Wakasa <kwakasa@google.com>2014-05-20 14:01:06 +0000
commit4e21d3711fb65e5b7ef24b2db7b5f2504365d5e3 (patch)
treedb692be994a4fc468dc754b1d86be77b772d29d8 /java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
parentff50b39176370ab80a33bfdcf9979603c08a88b3 (diff)
downloadlatinime-4e21d3711fb65e5b7ef24b2db7b5f2504365d5e3.tar.gz
latinime-4e21d3711fb65e5b7ef24b2db7b5f2504365d5e3.tar.xz
latinime-4e21d3711fb65e5b7ef24b2db7b5f2504365d5e3.zip
Revert "Use PrevWordsInfo for get/add/remove n-gram(bigram) entry."
This reverts commit ff50b39176370ab80a33bfdcf9979603c08a88b3. Bug: 14119293 Bug: 14425059 Bug: 15102610 Change-Id: If278b4ab236e38d20d8cdc0761b0438911bd4ff9
Diffstat (limited to 'java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java')
-rw-r--r--java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java28
1 files changed, 12 insertions, 16 deletions
diff --git a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
index f89caf921..818cd9a5f 100644
--- a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java
@@ -22,7 +22,6 @@ import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.ExpandableBinaryDictionary;
-import com.android.inputmethod.latin.PrevWordsInfo;
import java.io.File;
import java.util.Locale;
@@ -53,32 +52,29 @@ public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBas
}
/**
- * Add a word to the user history dictionary.
+ * Pair will be added to the user history dictionary.
*
- * @param userHistoryDictionary the user history dictionary
- * @param prevWordsInfo the information of previous words
- * @param word the word the user inputted
- * @param isValid whether the word is valid or not
- * @param timestamp the timestamp when the word has been inputted
+ * The first word may be null. That means we don't know the context, in other words,
+ * it's only a unigram. The first word may also be an empty string : this means start
+ * context, as in beginning of a sentence for example.
+ * The second word may not be null (a NullPointerException would be thrown).
*/
public static void addToDictionary(final ExpandableBinaryDictionary userHistoryDictionary,
- final PrevWordsInfo prevWordsInfo, final String word, final boolean isValid,
- final int timestamp) {
- final String prevWord = prevWordsInfo.mPrevWord;
- if (word.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH ||
- (prevWord != null && prevWord.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH)) {
+ final String word0, final String word1, final boolean isValid, final int timestamp) {
+ if (word1.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH ||
+ (word0 != null && word0.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH)) {
return;
}
final int frequency = isValid ?
FREQUENCY_FOR_WORDS_IN_DICTS : FREQUENCY_FOR_WORDS_NOT_IN_DICTS;
- userHistoryDictionary.addUnigramEntry(word, frequency, null /* shortcutTarget */,
+ userHistoryDictionary.addWordDynamically(word1, frequency, null /* shortcutTarget */,
0 /* shortcutFreq */, false /* isNotAWord */, false /* isBlacklisted */, timestamp);
// Do not insert a word as a bigram of itself
- if (word.equals(prevWord)) {
+ if (word1.equals(word0)) {
return;
}
- if (null != prevWord) {
- userHistoryDictionary.addNgramEntry(prevWordsInfo, word, frequency, timestamp);
+ if (null != word0) {
+ userHistoryDictionary.addBigramDynamically(word0, word1, frequency, timestamp);
}
}
}