Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54e84a00 authored by Jean Chalard's avatar Jean Chalard
Browse files

Make a makedict command for dicttool (A3)

This behaves exactly as the old makedict command. Further
changes will redirect the calls to makedict to this, so as
to consolidate similar code.

Groundwork for
Bug: 6429606

Change-Id: Ibeadbf48bec70f988a15ca36ebf5d1ce3b5b54ea
parent 1644a3c7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -61,8 +61,8 @@ public class FusionDictionary implements Iterable<Word> {
     * This represents an "attribute", that is either a bigram or a shortcut.
     */
    public static class WeightedString {
        final String mWord;
        int mFrequency;
        public final String mWord;
        public int mFrequency;
        public WeightedString(String word, int frequency) {
            mWord = word;
            mFrequency = frequency;
+4 −4
Original line number Diff line number Diff line
@@ -27,10 +27,10 @@ import java.util.Arrays;
 * This is chiefly used to iterate a dictionary.
 */
public class Word implements Comparable<Word> {
    final String mWord;
    final int mFrequency;
    final ArrayList<WeightedString> mShortcutTargets;
    final ArrayList<WeightedString> mBigrams;
    public final String mWord;
    public final int mFrequency;
    public final ArrayList<WeightedString> mShortcutTargets;
    public final ArrayList<WeightedString> mBigrams;

    private int mHashCode = 0;

+8 −1
Original line number Diff line number Diff line
@@ -16,9 +16,16 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES := $(call all-java-files-under,src)
MAKEDICT_CORE_SOURCE_DIRECTORY := ../../java/src/com/android/inputmethod/latin/makedict

LOCAL_MAIN_SRC_FILES := $(call all-java-files-under,$(MAKEDICT_CORE_SOURCE_DIRECTORY))
LOCAL_TOOL_SRC_FILES := $(call all-java-files-under,src)
LOCAL_SRC_FILES := $(LOCAL_TOOL_SRC_FILES) \
        $(filter-out $(addprefix %/, $(notdir $(LOCAL_TOOL_SRC_FILES))), $(LOCAL_MAIN_SRC_FILES)) \
        $(call all-java-files-under,tests)
LOCAL_JAR_MANIFEST := etc/manifest.txt
LOCAL_MODULE := dicttool
LOCAL_JAVA_LIBRARIES := junit
LOCAL_MODULE_TAGS := eng

include $(BUILD_HOST_JAVA_LIBRARY)
+12 −3
Original line number Diff line number Diff line
@@ -14,7 +14,12 @@
 * the License.
 */

package com.android.inputmethod.latin.makedict;
package com.android.inputmethod.latin.dicttool;

import com.android.inputmethod.latin.makedict.BinaryDictInputOutput;
import com.android.inputmethod.latin.makedict.FusionDictionary;
import com.android.inputmethod.latin.makedict.MakedictLog;
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;

import java.io.File;
import java.io.FileInputStream;
@@ -102,7 +107,11 @@ public class DictionaryMaker {
        }

        private void displayHelp() {
            MakedictLog.i("Usage: makedict "
            MakedictLog.i(getHelp());
        }

        public static String getHelp() {
            return "Usage: makedict "
                    + "[-s <unigrams.xml> [-b <bigrams.xml>] [-c <shortcuts.xml>] "
                    + "| -s <binary input>] [-d <binary output format version 2>] "
                    + "[-d1 <binary output format version 1>] [-x <xml output>] [-2]\n"
@@ -114,7 +123,7 @@ public class DictionaryMaker {
                    + "  are supported. All three can be output at the same time, but the same\n"
                    + "  output format cannot be specified several times. The behavior is\n"
                    + "  unspecified if the same file is specified for input and output, or for\n"
                    + "  several outputs.");
                    + "  several outputs.";
        }

        public Arguments(String[] argsArray) throws IOException {
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ public class Dicttool {
        sCommands.put("info", Info.class);
        sCommands.put("compress", Compress.Compressor.class);
        sCommands.put("uncompress", Compress.Uncompressor.class);
        sCommands.put("makedict", Makedict.class);
    }

    private static Command getCommandInstance(final String commandName) {
Loading