aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Dictionary.java
diff options
context:
space:
mode:
authorJae Yong Sung <jysung@google.com>2010-06-30 20:28:04 -0700
committerJae Yong Sung <jysung@google.com>2010-07-13 11:33:39 -0700
commit937d5ad0131267aa4273f3e5d75b203a1f263c18 (patch)
treeb4a3bb6206aea92f5bacc3ebc1387ffdd5916f0c /java/src/com/android/inputmethod/latin/Dictionary.java
parentb71547f2d065a17b268d1dbc896daab1820141a6 (diff)
downloadlatinime-937d5ad0131267aa4273f3e5d75b203a1f263c18.tar.gz
latinime-937d5ad0131267aa4273f3e5d75b203a1f263c18.tar.xz
latinime-937d5ad0131267aa4273f3e5d75b203a1f263c18.zip
added bigram prediction
- after first character, only suggests bigram data (but doesn't autocomplete) - after second character, words from dictionary gets rearranged by using bigram - compatible with old dictionary - added preference option to disable bigram Change-Id: Ia8f4e8fa55e797e86d858fd499887cd396388411
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Dictionary.java')
-rw-r--r--java/src/com/android/inputmethod/latin/Dictionary.java29
1 files changed, 26 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/Dictionary.java b/java/src/com/android/inputmethod/latin/Dictionary.java
index e7b526663..54317c861 100644
--- a/java/src/com/android/inputmethod/latin/Dictionary.java
+++ b/java/src/com/android/inputmethod/latin/Dictionary.java
@@ -21,7 +21,9 @@ package com.android.inputmethod.latin;
* strokes.
*/
abstract public class Dictionary {
-
+
+ protected static final int MAX_WORD_LENGTH = 48;
+
/**
* Whether or not to replicate the typed word in the suggested list, even if it's valid.
*/
@@ -31,7 +33,11 @@ abstract public class Dictionary {
* The weight to give to a word if it's length is the same as the number of typed characters.
*/
protected static final int FULL_WORD_FREQ_MULTIPLIER = 2;
-
+
+ public static enum DataType {
+ UNIGRAM, BIGRAM
+ }
+
/**
* Interface to be implemented by classes requesting words to be fetched from the dictionary.
* @see #getWords(WordComposer, WordCallback)
@@ -45,9 +51,11 @@ abstract public class Dictionary {
* @param wordLength length of valid characters in the character array
* @param frequency the frequency of occurence. This is normalized between 1 and 255, but
* can exceed those limits
+ * @param dataType tells type of this data
* @return true if the word was added, false if no more words are required
*/
- boolean addWord(char[] word, int wordOffset, int wordLength, int frequency);
+ boolean addWord(char[] word, int wordOffset, int wordLength, int frequency,
+ DataType dataType);
}
/**
@@ -65,6 +73,21 @@ abstract public class Dictionary {
int[] nextLettersFrequencies);
/**
+ * Searches for pairs in the bigram dictionary that matches the previous word and all the
+ * possible words following are added through the callback object.
+ * @param composer the key sequence to match
+ * @param callback the callback object to send possible word following previous word
+ * @param nextLettersFrequencies array of frequencies of next letters that could follow the
+ * word so far. For instance, "bracke" can be followed by "t", so array['t'] will have
+ * a non-zero value on returning from this method.
+ * Pass in null if you don't want the dictionary to look up next letters.
+ */
+ public void getBigrams(final WordComposer composer, final CharSequence previousWord,
+ final WordCallback callback, int[] nextLettersFrequencies) {
+ // empty base implementation
+ }
+
+ /**
* Checks if the given word occurs in the dictionary
* @param word the word to search for. The search should be case-insensitive.
* @return true if the word exists, false otherwise