Loading java/src/com/android/inputmethod/latin/UserHistoryDictionary.java +7 −8 Original line number Diff line number Diff line Loading @@ -52,14 +52,14 @@ public class UserHistoryDictionary extends ExpandableDictionary { private static final int FREQUENCY_FOR_TYPED = 2; /** Maximum number of pairs. Pruning will start when databases goes above this number. */ private static int sMaxHistoryBigrams = 10000; public static final int sMaxHistoryBigrams = 10000; /** * When it hits maximum bigram pair, it will delete until you are left with * only (sMaxHistoryBigrams - sDeleteHistoryBigrams) pairs. * Do not keep this number small to avoid deleting too often. */ private static int sDeleteHistoryBigrams = 1000; public static final int sDeleteHistoryBigrams = 1000; /** * Database version should increase if the database structure changes Loading Loading @@ -109,12 +109,8 @@ public class UserHistoryDictionary extends ExpandableDictionary { private static DatabaseHelper sOpenHelper = null; public void setDatabaseMax(int maxHistoryBigram) { sMaxHistoryBigrams = maxHistoryBigram; } public void setDatabaseDelete(int deleteHistoryBigram) { sDeleteHistoryBigrams = deleteHistoryBigram; public String getLocale() { return mLocale; } public synchronized static UserHistoryDictionary getInstance( Loading Loading @@ -502,9 +498,11 @@ public class UserHistoryDictionary extends ExpandableDictionary { needsToSave(fc, isValid, addLevel0Bigram)) { freq = fc; } else { // Delete this entry freq = -1; } } else { // Delete this entry freq = -1; } } Loading Loading @@ -541,6 +539,7 @@ public class UserHistoryDictionary extends ExpandableDictionary { getContentValues(word1, word2, mLocale)); pairId = pairIdLong.intValue(); } // Eliminate freq == 0 because that word is profanity. if (freq > 0) { if (PROFILE_SAVE_RESTORE) { ++profInsert; Loading java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java +18 −0 Original line number Diff line number Diff line Loading @@ -1410,4 +1410,22 @@ public class BinaryDictInputOutput { return false; } } /** * Calculate bigram frequency from compressed value * * @see #makeBigramFlags * * @param unigramFrequency * @param bigramFrequency compressed frequency * @return approximate bigram frequency */ public static int reconstructBigramFrequency(final int unigramFrequency, final int bigramFrequency) { final float stepSize = (MAX_TERMINAL_FREQUENCY - unigramFrequency) / (1.5f + MAX_BIGRAM_FREQUENCY); final float resultFreqFloat = (float)unigramFrequency + stepSize * (bigramFrequency + 1.0f); return (int)resultFreqFloat; } } Loading
java/src/com/android/inputmethod/latin/UserHistoryDictionary.java +7 −8 Original line number Diff line number Diff line Loading @@ -52,14 +52,14 @@ public class UserHistoryDictionary extends ExpandableDictionary { private static final int FREQUENCY_FOR_TYPED = 2; /** Maximum number of pairs. Pruning will start when databases goes above this number. */ private static int sMaxHistoryBigrams = 10000; public static final int sMaxHistoryBigrams = 10000; /** * When it hits maximum bigram pair, it will delete until you are left with * only (sMaxHistoryBigrams - sDeleteHistoryBigrams) pairs. * Do not keep this number small to avoid deleting too often. */ private static int sDeleteHistoryBigrams = 1000; public static final int sDeleteHistoryBigrams = 1000; /** * Database version should increase if the database structure changes Loading Loading @@ -109,12 +109,8 @@ public class UserHistoryDictionary extends ExpandableDictionary { private static DatabaseHelper sOpenHelper = null; public void setDatabaseMax(int maxHistoryBigram) { sMaxHistoryBigrams = maxHistoryBigram; } public void setDatabaseDelete(int deleteHistoryBigram) { sDeleteHistoryBigrams = deleteHistoryBigram; public String getLocale() { return mLocale; } public synchronized static UserHistoryDictionary getInstance( Loading Loading @@ -502,9 +498,11 @@ public class UserHistoryDictionary extends ExpandableDictionary { needsToSave(fc, isValid, addLevel0Bigram)) { freq = fc; } else { // Delete this entry freq = -1; } } else { // Delete this entry freq = -1; } } Loading Loading @@ -541,6 +539,7 @@ public class UserHistoryDictionary extends ExpandableDictionary { getContentValues(word1, word2, mLocale)); pairId = pairIdLong.intValue(); } // Eliminate freq == 0 because that word is profanity. if (freq > 0) { if (PROFILE_SAVE_RESTORE) { ++profInsert; Loading
java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java +18 −0 Original line number Diff line number Diff line Loading @@ -1410,4 +1410,22 @@ public class BinaryDictInputOutput { return false; } } /** * Calculate bigram frequency from compressed value * * @see #makeBigramFlags * * @param unigramFrequency * @param bigramFrequency compressed frequency * @return approximate bigram frequency */ public static int reconstructBigramFrequency(final int unigramFrequency, final int bigramFrequency) { final float stepSize = (MAX_TERMINAL_FREQUENCY - unigramFrequency) / (1.5f + MAX_BIGRAM_FREQUENCY); final float resultFreqFloat = (float)unigramFrequency + stepSize * (bigramFrequency + 1.0f); return (int)resultFreqFloat; } }