Loading java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +3 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.util.Log; import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.makedict.BinaryDictInputOutput; import com.android.inputmethod.latin.makedict.FormatSpec; import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.FusionDictionary.Node; import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; Loading Loading @@ -90,8 +91,8 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { private final DictionaryController mLocalDictionaryController = new DictionaryController(); private static final int BINARY_DICT_VERSION = 1; private static final BinaryDictInputOutput.FormatOptions FORMAT_OPTIONS = new BinaryDictInputOutput.FormatOptions(BINARY_DICT_VERSION); private static final FormatSpec.FormatOptions FORMAT_OPTIONS = new FormatSpec.FormatOptions(BINARY_DICT_VERSION); /** * Abstract method for loading the unigrams and bigrams of a given dictionary in a background Loading java/src/com/android/inputmethod/latin/UserHistoryDictIOUtils.java +1 −1 Original line number Diff line number Diff line Loading @@ -19,8 +19,8 @@ package com.android.inputmethod.latin; import android.util.Log; import com.android.inputmethod.latin.makedict.BinaryDictInputOutput; import com.android.inputmethod.latin.makedict.BinaryDictInputOutput.FormatOptions; import com.android.inputmethod.latin.makedict.BinaryDictInputOutput.FusionDictionaryBufferInterface; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.FusionDictionary.Node; import com.android.inputmethod.latin.makedict.PendingAttribute; Loading java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java +2 −34 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.inputmethod.latin.makedict; import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup; import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions; import com.android.inputmethod.latin.makedict.FusionDictionary.Node; Loading Loading @@ -107,40 +109,6 @@ public class BinaryDictInputOutput { } } /** * Options about file format. */ public static class FormatOptions { public final int mVersion; public final boolean mHasParentAddress; public FormatOptions(final int version) { this(version, false); } public FormatOptions(final int version, final boolean hasParentAddress) { mVersion = version; if (version < FormatSpec.FIRST_VERSION_WITH_PARENT_ADDRESS && hasParentAddress) { throw new RuntimeException("Parent addresses are only supported with versions " + FormatSpec.FIRST_VERSION_WITH_PARENT_ADDRESS + " and ulterior."); } mHasParentAddress = hasParentAddress; } } /** * Class representing file header. */ private static final class FileHeader { public final int mHeaderSize; public final DictionaryOptions mDictionaryOptions; public final FormatOptions mFormatOptions; public FileHeader(final int headerSize, final DictionaryOptions dictionaryOptions, final FormatOptions formatOptions) { mHeaderSize = headerSize; mDictionaryOptions = dictionaryOptions; mFormatOptions = formatOptions; } } /** * A class grouping utility function for our specific character encoding. */ Loading java/src/com/android/inputmethod/latin/makedict/FormatSpec.java +35 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.inputmethod.latin.makedict; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions; /** * Dictionary File Format Specification. Loading Loading @@ -194,6 +195,40 @@ public final class FormatSpec { static final int MAX_TERMINAL_FREQUENCY = 255; static final int MAX_BIGRAM_FREQUENCY = 15; /** * Options about file format. */ public static class FormatOptions { public final int mVersion; public final boolean mHasParentAddress; public FormatOptions(final int version) { this(version, false); } public FormatOptions(final int version, final boolean hasParentAddress) { mVersion = version; if (version < FormatSpec.FIRST_VERSION_WITH_PARENT_ADDRESS && hasParentAddress) { throw new RuntimeException("Parent addresses are only supported with versions " + FormatSpec.FIRST_VERSION_WITH_PARENT_ADDRESS + " and ulterior."); } mHasParentAddress = hasParentAddress; } } /** * Class representing file header. */ static final class FileHeader { public final int mHeaderSize; public final DictionaryOptions mDictionaryOptions; public final FormatOptions mFormatOptions; public FileHeader(final int headerSize, final DictionaryOptions dictionaryOptions, final FormatOptions formatOptions) { mHeaderSize = headerSize; mDictionaryOptions = dictionaryOptions; mFormatOptions = formatOptions; } } private FormatSpec() { // This utility class is not publicly instantiable. } Loading tests/src/com/android/inputmethod/latin/UserHistoryDictIOUtilsTests.java +2 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.inputmethod.latin; import com.android.inputmethod.latin.UserHistoryDictIOUtils.BigramDictionaryInterface; import com.android.inputmethod.latin.UserHistoryDictIOUtils.OnAddWordListener; import com.android.inputmethod.latin.makedict.BinaryDictInputOutput; import com.android.inputmethod.latin.makedict.FormatSpec; import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup; Loading @@ -45,8 +46,7 @@ public class UserHistoryDictIOUtilsTests extends AndroidTestCase private static final int UNIGRAM_FREQUENCY = 50; private static final int BIGRAM_FREQUENCY = 100; private static final ArrayList<String> NOT_HAVE_BIGRAM = new ArrayList<String>(); private static final BinaryDictInputOutput.FormatOptions FORMAT_OPTIONS = new BinaryDictInputOutput.FormatOptions(2); private static final FormatSpec.FormatOptions FORMAT_OPTIONS = new FormatSpec.FormatOptions(2); /** * Return same frequency for all words and bigrams Loading Loading
java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +3 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.util.Log; import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.makedict.BinaryDictInputOutput; import com.android.inputmethod.latin.makedict.FormatSpec; import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.FusionDictionary.Node; import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString; Loading Loading @@ -90,8 +91,8 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { private final DictionaryController mLocalDictionaryController = new DictionaryController(); private static final int BINARY_DICT_VERSION = 1; private static final BinaryDictInputOutput.FormatOptions FORMAT_OPTIONS = new BinaryDictInputOutput.FormatOptions(BINARY_DICT_VERSION); private static final FormatSpec.FormatOptions FORMAT_OPTIONS = new FormatSpec.FormatOptions(BINARY_DICT_VERSION); /** * Abstract method for loading the unigrams and bigrams of a given dictionary in a background Loading
java/src/com/android/inputmethod/latin/UserHistoryDictIOUtils.java +1 −1 Original line number Diff line number Diff line Loading @@ -19,8 +19,8 @@ package com.android.inputmethod.latin; import android.util.Log; import com.android.inputmethod.latin.makedict.BinaryDictInputOutput; import com.android.inputmethod.latin.makedict.BinaryDictInputOutput.FormatOptions; import com.android.inputmethod.latin.makedict.BinaryDictInputOutput.FusionDictionaryBufferInterface; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.FusionDictionary.Node; import com.android.inputmethod.latin.makedict.PendingAttribute; Loading
java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java +2 −34 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.inputmethod.latin.makedict; import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup; import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions; import com.android.inputmethod.latin.makedict.FusionDictionary.Node; Loading Loading @@ -107,40 +109,6 @@ public class BinaryDictInputOutput { } } /** * Options about file format. */ public static class FormatOptions { public final int mVersion; public final boolean mHasParentAddress; public FormatOptions(final int version) { this(version, false); } public FormatOptions(final int version, final boolean hasParentAddress) { mVersion = version; if (version < FormatSpec.FIRST_VERSION_WITH_PARENT_ADDRESS && hasParentAddress) { throw new RuntimeException("Parent addresses are only supported with versions " + FormatSpec.FIRST_VERSION_WITH_PARENT_ADDRESS + " and ulterior."); } mHasParentAddress = hasParentAddress; } } /** * Class representing file header. */ private static final class FileHeader { public final int mHeaderSize; public final DictionaryOptions mDictionaryOptions; public final FormatOptions mFormatOptions; public FileHeader(final int headerSize, final DictionaryOptions dictionaryOptions, final FormatOptions formatOptions) { mHeaderSize = headerSize; mDictionaryOptions = dictionaryOptions; mFormatOptions = formatOptions; } } /** * A class grouping utility function for our specific character encoding. */ Loading
java/src/com/android/inputmethod/latin/makedict/FormatSpec.java +35 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.inputmethod.latin.makedict; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions; /** * Dictionary File Format Specification. Loading Loading @@ -194,6 +195,40 @@ public final class FormatSpec { static final int MAX_TERMINAL_FREQUENCY = 255; static final int MAX_BIGRAM_FREQUENCY = 15; /** * Options about file format. */ public static class FormatOptions { public final int mVersion; public final boolean mHasParentAddress; public FormatOptions(final int version) { this(version, false); } public FormatOptions(final int version, final boolean hasParentAddress) { mVersion = version; if (version < FormatSpec.FIRST_VERSION_WITH_PARENT_ADDRESS && hasParentAddress) { throw new RuntimeException("Parent addresses are only supported with versions " + FormatSpec.FIRST_VERSION_WITH_PARENT_ADDRESS + " and ulterior."); } mHasParentAddress = hasParentAddress; } } /** * Class representing file header. */ static final class FileHeader { public final int mHeaderSize; public final DictionaryOptions mDictionaryOptions; public final FormatOptions mFormatOptions; public FileHeader(final int headerSize, final DictionaryOptions dictionaryOptions, final FormatOptions formatOptions) { mHeaderSize = headerSize; mDictionaryOptions = dictionaryOptions; mFormatOptions = formatOptions; } } private FormatSpec() { // This utility class is not publicly instantiable. } Loading
tests/src/com/android/inputmethod/latin/UserHistoryDictIOUtilsTests.java +2 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.inputmethod.latin; import com.android.inputmethod.latin.UserHistoryDictIOUtils.BigramDictionaryInterface; import com.android.inputmethod.latin.UserHistoryDictIOUtils.OnAddWordListener; import com.android.inputmethod.latin.makedict.BinaryDictInputOutput; import com.android.inputmethod.latin.makedict.FormatSpec; import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup; Loading @@ -45,8 +46,7 @@ public class UserHistoryDictIOUtilsTests extends AndroidTestCase private static final int UNIGRAM_FREQUENCY = 50; private static final int BIGRAM_FREQUENCY = 100; private static final ArrayList<String> NOT_HAVE_BIGRAM = new ArrayList<String>(); private static final BinaryDictInputOutput.FormatOptions FORMAT_OPTIONS = new BinaryDictInputOutput.FormatOptions(2); private static final FormatSpec.FormatOptions FORMAT_OPTIONS = new FormatSpec.FormatOptions(2); /** * Return same frequency for all words and bigrams Loading