Rename BinaryDictDecoder to Ver3DictDecoder.

Change-Id: Ibf9b95b658df6e2c2218bdb62e2380f326a03832
main
Yuichiro Hanada 2013-08-20 15:48:16 +09:00
parent 66004ce2de
commit 112257e40f
20 changed files with 81 additions and 86 deletions

View File

@ -21,21 +21,16 @@ import android.content.SharedPreferences;
import android.content.res.AssetFileDescriptor;
import android.util.Log;
import com.android.inputmethod.latin.makedict.BinaryDictDecoder;
import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils;
import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.DictBuffer;
import com.android.inputmethod.latin.makedict.FormatSpec;
import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader;
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import com.android.inputmethod.latin.makedict.Ver3DictDecoder;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.DictionaryInfoUtils;
import com.android.inputmethod.latin.utils.LocaleUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.BufferUnderflowException;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
@ -233,9 +228,9 @@ final public class BinaryDictionaryGetter {
private static boolean hackCanUseDictionaryFile(final Locale locale, final File f) {
try {
// Read the version of the file
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(f);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(f);
dictDecoder.openDictBuffer(
new BinaryDictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
final FileHeader header = dictDecoder.readHeader();
final String version = header.mDictionaryOptions.mAttributes.get(VERSION_KEY);

View File

@ -40,7 +40,7 @@ import java.util.TreeMap;
*
* All the methods in this class are static.
*
* TODO: Remove calls from classes except BinaryDictDecoder
* TODO: Remove calls from classes except Ver3DictDecoder
* TODO: Move this file to makedict/internal.
*/
public final class BinaryDictDecoderUtils {
@ -649,13 +649,13 @@ public final class BinaryDictDecoderUtils {
* @return the created (or merged) dictionary.
*/
@UsedForTesting
public static FusionDictionary readDictionaryBinary(final BinaryDictDecoder dictDecoder,
public static FusionDictionary readDictionaryBinary(final Ver3DictDecoder dictDecoder,
final FusionDictionary dict) throws FileNotFoundException, IOException,
UnsupportedFormatException {
// if the buffer has not been opened, open the buffer with bytebuffer.
if (dictDecoder.getDictBuffer() == null) dictDecoder.openDictBuffer(
new BinaryDictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
if (dictDecoder.getDictBuffer() == null) {
MakedictLog.e("Cannot open the buffer");
}

View File

@ -148,7 +148,7 @@ public final class BinaryDictIOUtils {
* @throws IOException if the file can't be read.
* @throws UnsupportedFormatException if the format of the file is not recognized.
*/
public static void readUnigramsAndBigramsBinary(final BinaryDictDecoder dictDecoder,
public static void readUnigramsAndBigramsBinary(final Ver3DictDecoder dictDecoder,
final Map<Integer, String> words, final Map<Integer, Integer> frequencies,
final Map<Integer, ArrayList<PendingAttribute>> bigrams) throws IOException,
UnsupportedFormatException {
@ -169,7 +169,7 @@ public final class BinaryDictIOUtils {
* @throws UnsupportedFormatException if the format of the file is not recognized.
*/
@UsedForTesting
public static int getTerminalPosition(final BinaryDictDecoder dictDecoder,
public static int getTerminalPosition(final Ver3DictDecoder dictDecoder,
final String word) throws IOException, UnsupportedFormatException {
final DictBuffer dictBuffer = dictDecoder.getDictBuffer();
if (word == null) return FormatSpec.NOT_VALID_WORD;
@ -508,7 +508,7 @@ public final class BinaryDictIOUtils {
}
/**
* Find a word using the BinaryDictDecoder.
* Find a word using the Ver3DictDecoder.
*
* @param dictDecoder the dict reader
* @param word the word searched
@ -517,7 +517,7 @@ public final class BinaryDictIOUtils {
* @throws UnsupportedFormatException
*/
@UsedForTesting
public static CharGroupInfo findWordByBinaryDictReader(final BinaryDictDecoder dictDecoder,
public static CharGroupInfo findWordByBinaryDictReader(final Ver3DictDecoder dictDecoder,
final String word) throws IOException, UnsupportedFormatException {
int position = getTerminalPosition(dictDecoder, word);
final DictBuffer dictBuffer = dictDecoder.getDictBuffer();
@ -545,8 +545,8 @@ public final class BinaryDictIOUtils {
final File file, final long offset, final long length)
throws FileNotFoundException, IOException, UnsupportedFormatException {
final byte[] buffer = new byte[HEADER_READING_BUFFER_SIZE];
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(file);
dictDecoder.openDictBuffer(new BinaryDictDecoder.DictionaryBufferFactory() {
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file);
dictDecoder.openDictBuffer(new Ver3DictDecoder.DictionaryBufferFactory() {
@Override
public DictBuffer getDictionaryBuffer(File file)
throws FileNotFoundException, IOException {

View File

@ -55,7 +55,7 @@ public final class DynamicBinaryDictIOUtils {
* @throws UnsupportedFormatException
*/
@UsedForTesting
public static void deleteWord(final BinaryDictDecoder dictDecoder, final String word)
public static void deleteWord(final Ver3DictDecoder dictDecoder, final String word)
throws IOException, UnsupportedFormatException {
final DictBuffer dictBuffer = dictDecoder.getDictBuffer();
dictBuffer.position(0);
@ -253,7 +253,7 @@ public final class DynamicBinaryDictIOUtils {
// TODO: Support batch insertion.
// TODO: Remove @UsedForTesting once UserHistoryDictionary is implemented by BinaryDictionary.
@UsedForTesting
public static void insertWord(final BinaryDictDecoder dictDecoder,
public static void insertWord(final Ver3DictDecoder dictDecoder,
final OutputStream destination, final String word, final int frequency,
final ArrayList<WeightedString> bigramStrings,
final ArrayList<WeightedString> shortcuts, final boolean isNotAWord,

View File

@ -33,9 +33,9 @@ import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.HashMap;
// TODO: Rename this class to "Ver3DictDecoder" or something, and make an interface "DictDecoder".
// TODO: Make an interface "DictDecoder".
@UsedForTesting
public class BinaryDictDecoder {
public class Ver3DictDecoder {
static {
JniUtils.loadNativeLibrary();
@ -166,7 +166,7 @@ public class BinaryDictDecoder {
private final File mDictionaryBinaryFile;
private DictBuffer mDictBuffer;
public BinaryDictDecoder(final File file) {
public Ver3DictDecoder(final File file) {
mDictionaryBinaryFile = file;
mDictBuffer = null;
}

View File

@ -28,8 +28,8 @@ import com.android.inputmethod.latin.ExpandableDictionary;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.WordComposer;
import com.android.inputmethod.latin.makedict.BinaryDictDecoder;
import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions;
import com.android.inputmethod.latin.makedict.Ver3DictDecoder;
import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils;
@ -241,10 +241,10 @@ public abstract class DynamicPredictionDictionaryBase extends ExpandableDictiona
};
// Load the dictionary from binary file
final BinaryDictDecoder reader = new BinaryDictDecoder(
final Ver3DictDecoder reader = new Ver3DictDecoder(
new File(getContext().getFilesDir(), fileName));
try {
reader.openDictBuffer(new BinaryDictDecoder.DictionaryBufferFromByteArrayFactory());
reader.openDictBuffer(new Ver3DictDecoder.DictionaryBufferFromByteArrayFactory());
UserHistoryDictIOUtils.readDictionaryBinary(reader, listener);
} catch (FileNotFoundException e) {
// This is an expected condition: we don't have a user history dictionary for this

View File

@ -19,7 +19,6 @@ package com.android.inputmethod.latin.utils;
import android.util.Log;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.makedict.BinaryDictDecoder;
import com.android.inputmethod.latin.makedict.BinaryDictEncoder;
import com.android.inputmethod.latin.makedict.BinaryDictIOUtils;
import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions;
@ -27,6 +26,7 @@ import com.android.inputmethod.latin.makedict.FusionDictionary;
import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray;
import com.android.inputmethod.latin.makedict.PendingAttribute;
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import com.android.inputmethod.latin.makedict.Ver3DictDecoder;
import com.android.inputmethod.latin.personalization.UserHistoryDictionaryBigramList;
import java.io.IOException;
@ -118,7 +118,7 @@ public final class UserHistoryDictIOUtils {
/**
* Reads dictionary from file.
*/
public static void readDictionaryBinary(final BinaryDictDecoder dictDecoder,
public static void readDictionaryBinary(final Ver3DictDecoder dictDecoder,
final OnAddWordListener dict) {
final Map<Integer, String> unigrams = CollectionUtils.newTreeMap();
final Map<Integer, Integer> frequencies = CollectionUtils.newTreeMap();

View File

@ -43,7 +43,7 @@ LATIN_IME_JNI_SRC_FILES := \
com_android_inputmethod_keyboard_ProximityInfo.cpp \
com_android_inputmethod_latin_BinaryDictionary.cpp \
com_android_inputmethod_latin_DicTraverseSession.cpp \
com_android_inputmethod_latin_makedict_BinaryDictDecoder.cpp \
com_android_inputmethod_latin_makedict_Ver3DictDecoder.cpp \
jni_common.cpp
LATIN_IME_CORE_SRC_FILES := \

View File

@ -14,16 +14,16 @@
* limitations under the License.
*/
#define LOG_TAG "LatinIME: jni: BinaryDictDecoder"
#define LOG_TAG "LatinIME: jni: Ver3DictDecoder"
#include "com_android_inputmethod_latin_makedict_BinaryDictDecoder.h"
#include "com_android_inputmethod_latin_makedict_Ver3DictDecoder.h"
#include "defines.h"
#include "jni.h"
#include "jni_common.h"
namespace latinime {
static int latinime_BinaryDictDecoder_doNothing(JNIEnv *env, jclass clazz) {
static int latinime_Ver3DictDecoder_doNothing(JNIEnv *env, jclass clazz) {
// This is a phony method for test - it does nothing. It just returns some value
// unlikely to be in memory by chance for testing purposes.
// TODO: remove this method.
@ -35,13 +35,13 @@ static const JNINativeMethod sMethods[] = {
// TODO: remove this entry when we have one useful method in here
const_cast<char *>("doNothing"),
const_cast<char *>("()I"),
reinterpret_cast<void *>(latinime_BinaryDictDecoder_doNothing)
reinterpret_cast<void *>(latinime_Ver3DictDecoder_doNothing)
},
};
int register_BinaryDictDecoder(JNIEnv *env) {
int register_Ver3DictDecoder(JNIEnv *env) {
const char *const kClassPathName =
"com/android/inputmethod/latin/makedict/BinaryDictDecoder";
"com/android/inputmethod/latin/makedict/Ver3DictDecoder";
return registerNativeMethods(env, kClassPathName, sMethods, NELEMS(sMethods));
}
} // namespace latinime

View File

@ -14,12 +14,12 @@
* limitations under the License.
*/
#ifndef _COM_ANDROID_INPUTMETHOD_LATIN_MAKEDICT_BINARYDICTDECODER_H
#define _COM_ANDROID_INPUTMETHOD_LATIN_MAKEDICT_BINARYDICTDECODER_H
#ifndef _COM_ANDROID_INPUTMETHOD_LATIN_MAKEDICT_VER3DICTDECODER_H
#define _COM_ANDROID_INPUTMETHOD_LATIN_MAKEDICT_VER3DICTDECODER_H
#include "jni.h"
namespace latinime {
int register_BinaryDictDecoder(JNIEnv *env);
int register_Ver3DictDecoder(JNIEnv *env);
} // namespace latinime
#endif // _COM_ANDROID_INPUTMETHOD_LATIN_MAKEDICT_BINARYDICTDECODER_H
#endif // _COM_ANDROID_INPUTMETHOD_LATIN_MAKEDICT_VER3DICTDECODER_H

View File

@ -23,7 +23,7 @@
#include "com_android_inputmethod_latin_BinaryDictionary.h"
#include "com_android_inputmethod_latin_DicTraverseSession.h"
#endif
#include "com_android_inputmethod_latin_makedict_BinaryDictDecoder.h"
#include "com_android_inputmethod_latin_makedict_Ver3DictDecoder.h"
#include "defines.h"
/*
@ -55,8 +55,8 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
return -1;
}
#endif
if (!latinime::register_BinaryDictDecoder(env)) {
AKLOGE("ERROR: BinaryDictDecoder native registration failed");
if (!latinime::register_Ver3DictDecoder(env)) {
AKLOGE("ERROR: Ver3DictDecoder native registration failed");
return -1;
}
/* success -- return valid version number */

View File

@ -41,7 +41,7 @@ class ProbabilityUtils {
// the unigram probability to be the median value of the 17th step from the top. A value of
// 0 for the bigram probability represents the middle of the 16th step from the top,
// while a value of 15 represents the middle of the top step.
// See makedict.BinaryDictDecoder for details.
// See makedict.BinaryDictEncoder#makeBigramFlags for details.
const float stepSize = static_cast<float>(MAX_PROBABILITY - unigramProbability)
/ (1.5f + MAX_BIGRAM_ENCODED_PROBABILITY);
return unigramProbability

View File

@ -120,14 +120,14 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
/**
* Makes new DictBuffer according to BUFFER_TYPE.
*/
private void getDictBuffer(final BinaryDictDecoder dictDecoder, final int bufferType)
private void getDictBuffer(final Ver3DictDecoder dictDecoder, final int bufferType)
throws FileNotFoundException, IOException {
if (bufferType == USE_BYTE_BUFFER) {
dictDecoder.openDictBuffer(
new BinaryDictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
} else if (bufferType == USE_BYTE_ARRAY) {
dictDecoder.openDictBuffer(
new BinaryDictDecoder.DictionaryBufferFromByteArrayFactory());
new Ver3DictDecoder.DictionaryBufferFromByteArrayFactory());
}
}
@ -271,7 +271,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
final SparseArray<List<Integer>> bigrams, final Map<String, List<String>> shortcutMap,
final int bufferType) {
long now, diff = -1;
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(file);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file);
FusionDictionary dict = null;
try {
@ -409,7 +409,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
final Map<Integer, Integer> resultFreqs = CollectionUtils.newTreeMap();
long now = -1, diff = -1;
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(file);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file);
try {
getDictBuffer(dictDecoder, bufferType);
assertNotNull("Can't get buffer.", dictDecoder.getDictBuffer());
@ -499,7 +499,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
}
// Tests for getTerminalPosition
private String getWordFromBinary(final BinaryDictDecoder dictDecoder, final int address) {
private String getWordFromBinary(final Ver3DictDecoder dictDecoder, final int address) {
final DictBuffer dictBuffer = dictDecoder.getDictBuffer();
if (dictBuffer.position() != 0) dictBuffer.position(0);
@ -516,7 +516,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
address - fileHeader.mHeaderSize, fileHeader.mFormatOptions).mWord;
}
private long runGetTerminalPosition(final BinaryDictDecoder dictDecoder, final String word,
private long runGetTerminalPosition(final Ver3DictDecoder dictDecoder, final String word,
int index, boolean contained) {
final int expectedFrequency = (UNIGRAM_FREQ + index) % 255;
long diff = -1;
@ -552,10 +552,10 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
addUnigrams(sWords.size(), dict, sWords, null /* shortcutMap */);
timeWritingDictToFile(file, dict, VERSION3_WITH_DYNAMIC_UPDATE);
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(file);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file);
try {
dictDecoder.openDictBuffer(
new BinaryDictDecoder.DictionaryBufferFromByteArrayFactory());
new Ver3DictDecoder.DictionaryBufferFromByteArrayFactory());
} catch (IOException e) {
// ignore
Log.e(TAG, "IOException while opening the buffer", e);
@ -613,10 +613,10 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
addUnigrams(sWords.size(), dict, sWords, null /* shortcutMap */);
timeWritingDictToFile(file, dict, VERSION3_WITH_DYNAMIC_UPDATE);
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(file);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file);
try {
dictDecoder.openDictBuffer(
new BinaryDictDecoder.DictionaryBufferFromByteArrayFactory());
new Ver3DictDecoder.DictionaryBufferFromByteArrayFactory());
} catch (IOException e) {
// ignore
Log.e(TAG, "IOException while opening the buffer", e);

View File

@ -22,12 +22,12 @@ import android.test.suitebuilder.annotation.LargeTest;
import android.util.Log;
import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.DictBuffer;
import com.android.inputmethod.latin.makedict.BinaryDictDecoder.
DictionaryBufferFromWritableByteBufferFactory;
import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader;
import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray;
import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.makedict.Ver3DictDecoder.
DictionaryBufferFromWritableByteBufferFactory;
import java.io.BufferedOutputStream;
import java.io.File;
@ -128,7 +128,7 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase {
}
}
private static void printBinaryFile(final BinaryDictDecoder dictDecoder)
private static void printBinaryFile(final Ver3DictDecoder dictDecoder)
throws IOException, UnsupportedFormatException {
final FileHeader fileHeader = dictDecoder.readHeader();
final DictBuffer buffer = dictDecoder.getDictBuffer();
@ -139,12 +139,12 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase {
private int getWordPosition(final File file, final String word) {
int position = FormatSpec.NOT_VALID_WORD;
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(file);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file);
FileInputStream inStream = null;
try {
inStream = new FileInputStream(file);
dictDecoder.openDictBuffer(
new BinaryDictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
position = BinaryDictIOUtils.getTerminalPosition(dictDecoder, word);
} catch (IOException e) {
} catch (UnsupportedFormatException e) {
@ -161,11 +161,11 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase {
}
private CharGroupInfo findWordFromFile(final File file, final String word) {
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(file);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file);
CharGroupInfo info = null;
try {
dictDecoder.openDictBuffer(
new BinaryDictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
info = BinaryDictIOUtils.findWordByBinaryDictReader(dictDecoder, word);
} catch (IOException e) {
} catch (UnsupportedFormatException e) {
@ -177,7 +177,7 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase {
private long insertAndCheckWord(final File file, final String word, final int frequency,
final boolean exist, final ArrayList<WeightedString> bigrams,
final ArrayList<WeightedString> shortcuts) {
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(file);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file);
BufferedOutputStream outStream = null;
long amountOfTime = -1;
try {
@ -211,7 +211,7 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase {
}
private void deleteWord(final File file, final String word) {
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(file);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file);
try {
dictDecoder.openDictBuffer(new DictionaryBufferFromWritableByteBufferFactory());
DynamicBinaryDictIOUtils.deleteWord(dictDecoder, word);
@ -221,10 +221,10 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase {
}
private void checkReverseLookup(final File file, final String word, final int position) {
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(file);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file);
try {
final DictBuffer dictBuffer = dictDecoder.openAndGetDictBuffer(
new BinaryDictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
final FileHeader fileHeader = dictDecoder.readHeader();
assertEquals(word,
BinaryDictDecoderUtils.getWordAtAddress(dictDecoder.getDictBuffer(),

View File

@ -17,12 +17,12 @@
package com.android.inputmethod.latin.makedict;
import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.DictBuffer;
import com.android.inputmethod.latin.makedict.BinaryDictDecoder.DictionaryBufferFactory;
import com.android.inputmethod.latin.makedict.BinaryDictDecoder.
import com.android.inputmethod.latin.makedict.Ver3DictDecoder.DictionaryBufferFactory;
import com.android.inputmethod.latin.makedict.Ver3DictDecoder.
DictionaryBufferFromByteArrayFactory;
import com.android.inputmethod.latin.makedict.BinaryDictDecoder.
import com.android.inputmethod.latin.makedict.Ver3DictDecoder.
DictionaryBufferFromReadOnlyByteBufferFactory;
import com.android.inputmethod.latin.makedict.BinaryDictDecoder.
import com.android.inputmethod.latin.makedict.Ver3DictDecoder.
DictionaryBufferFromWritableByteBufferFactory;
import android.test.AndroidTestCase;
@ -33,10 +33,10 @@ import java.io.FileOutputStream;
import java.io.IOException;
/**
* Unit tests for BinaryDictDecoder
* Unit tests for Ver3DictDecoder
*/
public class BinaryDictDecoderTests extends AndroidTestCase {
private static final String TAG = BinaryDictDecoderTests.class.getSimpleName();
public class Ver3DictDecoderTests extends AndroidTestCase {
private static final String TAG = Ver3DictDecoderTests.class.getSimpleName();
private final byte[] data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
@ -70,7 +70,7 @@ public class BinaryDictDecoderTests extends AndroidTestCase {
}
assertNotNull(testFile);
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(testFile);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(testFile);
try {
dictDecoder.openDictBuffer(factory);
} catch (Exception e) {
@ -113,7 +113,7 @@ public class BinaryDictDecoderTests extends AndroidTestCase {
Log.e(TAG, "IOException while the creating temporary file", e);
}
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(testFile);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(testFile);
// the default return value of getBuffer() must be null.
assertNull("the default return value of getBuffer() is not null",

View File

@ -21,10 +21,10 @@ import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.LargeTest;
import android.util.Log;
import com.android.inputmethod.latin.makedict.BinaryDictDecoder;
import com.android.inputmethod.latin.makedict.FormatSpec;
import com.android.inputmethod.latin.makedict.FusionDictionary;
import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
import com.android.inputmethod.latin.makedict.Ver3DictDecoder;
import com.android.inputmethod.latin.personalization.UserHistoryDictionaryBigramList;
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.BigramDictionaryInterface;
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.OnAddWordListener;
@ -147,10 +147,10 @@ public class UserHistoryDictIOUtilsTests extends AndroidTestCase
}
private void readDictFromFile(final File file, final OnAddWordListener listener) {
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(file);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file);
try {
dictDecoder.openDictBuffer(
new BinaryDictDecoder.DictionaryBufferFromByteArrayFactory());
new Ver3DictDecoder.DictionaryBufferFromByteArrayFactory());
} catch (FileNotFoundException e) {
Log.e(TAG, "file not found", e);
} catch (IOException e) {

View File

@ -34,7 +34,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(LATINIME_NATIVE_SRC_DIR)
# Used in jni_common.cpp to avoid registering useless methods.
LATIN_IME_JNI_SRC_FILES := \
com_android_inputmethod_latin_makedict_BinaryDictDecoder.cpp \
com_android_inputmethod_latin_makedict_Ver3DictDecoder.cpp \
jni_common.cpp
LATIN_IME_CORE_SRC_FILES :=

View File

@ -17,9 +17,9 @@
package com.android.inputmethod.latin.dicttool;
import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils;
import com.android.inputmethod.latin.makedict.BinaryDictDecoder;
import com.android.inputmethod.latin.makedict.FusionDictionary;
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import com.android.inputmethod.latin.makedict.Ver3DictDecoder;
import org.xml.sax.SAXException;
@ -184,9 +184,9 @@ public final class BinaryDictOffdeviceUtils {
crash(filename, new RuntimeException(
filename + " does not seem to be a dictionary file"));
} else {
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(decodedSpec.mFile);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(decodedSpec.mFile);
dictDecoder.openDictBuffer(
new BinaryDictDecoder.DictionaryBufferFromByteArrayFactory());
new Ver3DictDecoder.DictionaryBufferFromByteArrayFactory());
if (report) {
System.out.println("Format : Binary dictionary format");
System.out.println("Packaging : " + decodedSpec.describeChain());

View File

@ -18,11 +18,11 @@ package com.android.inputmethod.latin.dicttool;
import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils;
import com.android.inputmethod.latin.makedict.BinaryDictEncoder;
import com.android.inputmethod.latin.makedict.BinaryDictDecoder;
import com.android.inputmethod.latin.makedict.FormatSpec;
import com.android.inputmethod.latin.makedict.FusionDictionary;
import com.android.inputmethod.latin.makedict.MakedictLog;
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import com.android.inputmethod.latin.makedict.Ver3DictDecoder;
import java.io.BufferedWriter;
import java.io.File;
@ -266,9 +266,9 @@ public class DictionaryMaker {
private static FusionDictionary readBinaryFile(final String binaryFilename)
throws FileNotFoundException, IOException, UnsupportedFormatException {
final File file = new File(binaryFilename);
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(file);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file);
dictDecoder.openDictBuffer(
new BinaryDictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
return BinaryDictDecoderUtils.readDictionaryBinary(dictDecoder, null);
}

View File

@ -16,7 +16,6 @@
package com.android.inputmethod.latin.dicttool;
import com.android.inputmethod.latin.makedict.BinaryDictDecoder;
import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils;
import com.android.inputmethod.latin.makedict.BinaryDictEncoder;
import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions;
@ -24,6 +23,7 @@ import com.android.inputmethod.latin.makedict.FusionDictionary;
import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions;
import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray;
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import com.android.inputmethod.latin.makedict.Ver3DictDecoder;
import junit.framework.TestCase;
@ -67,9 +67,9 @@ public class BinaryDictOffdeviceUtilsTests extends TestCase {
assertEquals("Wrong decode spec", BinaryDictOffdeviceUtils.COMPRESSION, step);
}
assertEquals("Wrong decode spec", 3, decodeSpec.mDecoderSpec.size());
final BinaryDictDecoder dictDecoder = new BinaryDictDecoder(decodeSpec.mFile);
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(decodeSpec.mFile);
dictDecoder.openDictBuffer(
new BinaryDictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
new Ver3DictDecoder.DictionaryBufferFromReadOnlyByteBufferFactory());
final FusionDictionary resultDict = BinaryDictDecoderUtils.readDictionaryBinary(dictDecoder,
null /* dict : an optional dictionary to add words to, or null */);
assertEquals("Dictionary can't be read back correctly",