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

Commit 0f7d881d authored by Mohammadinamul Sheik's avatar Mohammadinamul Sheik
Browse files

Move decoder specific constants to DecoderSpecificConstants.java

Change-Id: Ie4d325b3152e1e7e424b8b436e222e194e4d9da0
parent 608ef472
Loading
Loading
Loading
Loading
+0 −9
Original line number Original line Diff line number Diff line
@@ -173,15 +173,6 @@ public final class Constants {
    // right for this.
    // right for this.
    public static final int MAX_CHARACTERS_FOR_RECAPITALIZATION = 1024 * 100;
    public static final int MAX_CHARACTERS_FOR_RECAPITALIZATION = 1024 * 100;


    // Must be equal to MAX_WORD_LENGTH in native/jni/src/defines.h
    // TODO: create a overlay and update the value appropriately for the new decoder.
    public static final int DICTIONARY_MAX_WORD_LENGTH = 48;

    // (MAX_PREV_WORD_COUNT_FOR_N_GRAM + 1)-gram is supported in Java side. Needs to modify
    // MAX_PREV_WORD_COUNT_FOR_N_GRAM in native/jni/src/defines.h for suggestions.
    // TODO: create a overlay and update the value appropriately for the new decoder.
    public static final int MAX_PREV_WORD_COUNT_FOR_N_GRAM = 3;

    // Key events coming any faster than this are long-presses.
    // Key events coming any faster than this are long-presses.
    public static final int LONG_PRESS_MILLISECONDS = 200;
    public static final int LONG_PRESS_MILLISECONDS = 200;
    // TODO: Set this value appropriately.
    // TODO: Set this value appropriately.
+30 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.inputmethod.latin.define;

/**
 * Decoder specific constants for LatinIme.
 */
public class DecoderSpecificConstants {

    // Must be equal to MAX_WORD_LENGTH in native/jni/src/defines.h
    public static final int DICTIONARY_MAX_WORD_LENGTH = 48;

    // (MAX_PREV_WORD_COUNT_FOR_N_GRAM + 1)-gram is supported in Java side. Needs to modify
    // MAX_PREV_WORD_COUNT_FOR_N_GRAM in native/jni/src/defines.h for suggestions.
    public static final int MAX_PREV_WORD_COUNT_FOR_N_GRAM = 3;
}
+5 −4
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.inputmethod.latin.common.Constants;
import com.android.inputmethod.latin.common.FileUtils;
import com.android.inputmethod.latin.common.FileUtils;
import com.android.inputmethod.latin.common.InputPointers;
import com.android.inputmethod.latin.common.InputPointers;
import com.android.inputmethod.latin.common.StringUtils;
import com.android.inputmethod.latin.common.StringUtils;
import com.android.inputmethod.latin.define.DecoderSpecificConstants;
import com.android.inputmethod.latin.makedict.DictionaryHeader;
import com.android.inputmethod.latin.makedict.DictionaryHeader;
import com.android.inputmethod.latin.makedict.FormatSpec;
import com.android.inputmethod.latin.makedict.FormatSpec;
import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions;
import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions;
@@ -319,9 +320,9 @@ public final class BinaryDictionary extends Dictionary {
        final int count = session.mOutputSuggestionCount[0];
        final int count = session.mOutputSuggestionCount[0];
        final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<>();
        final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<>();
        for (int j = 0; j < count; ++j) {
        for (int j = 0; j < count; ++j) {
            final int start = j * Constants.DICTIONARY_MAX_WORD_LENGTH;
            final int start = j * DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH;
            int len = 0;
            int len = 0;
            while (len < Constants.DICTIONARY_MAX_WORD_LENGTH
            while (len < DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH
                    && session.mOutputCodePoints[start + len] != 0) {
                    && session.mOutputCodePoints[start + len] != 0) {
                ++len;
                ++len;
            }
            }
@@ -390,7 +391,7 @@ public final class BinaryDictionary extends Dictionary {
            return null;
            return null;
        }
        }
        final int[] codePoints = StringUtils.toCodePointArray(word);
        final int[] codePoints = StringUtils.toCodePointArray(word);
        final int[] outCodePoints = new int[Constants.DICTIONARY_MAX_WORD_LENGTH];
        final int[] outCodePoints = new int[DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH];
        final boolean[] outFlags = new boolean[FORMAT_WORD_PROPERTY_OUTPUT_FLAG_COUNT];
        final boolean[] outFlags = new boolean[FORMAT_WORD_PROPERTY_OUTPUT_FLAG_COUNT];
        final int[] outProbabilityInfo =
        final int[] outProbabilityInfo =
                new int[FORMAT_WORD_PROPERTY_OUTPUT_PROBABILITY_INFO_COUNT];
                new int[FORMAT_WORD_PROPERTY_OUTPUT_PROBABILITY_INFO_COUNT];
@@ -431,7 +432,7 @@ public final class BinaryDictionary extends Dictionary {
     * If token is 0, this method newly starts iterating the dictionary.
     * If token is 0, this method newly starts iterating the dictionary.
     */
     */
    public GetNextWordPropertyResult getNextWordProperty(final int token) {
    public GetNextWordPropertyResult getNextWordProperty(final int token) {
        final int[] codePoints = new int[Constants.DICTIONARY_MAX_WORD_LENGTH];
        final int[] codePoints = new int[DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH];
        final boolean[] isBeginningOfSentence = new boolean[1];
        final boolean[] isBeginningOfSentence = new boolean[1];
        final int nextToken = getNextWordNative(mNativeDict, token, codePoints,
        final int nextToken = getNextWordNative(mNativeDict, token, codePoints,
                isBeginningOfSentence);
                isBeginningOfSentence);
+6 −5
Original line number Original line Diff line number Diff line
@@ -16,8 +16,8 @@


package com.android.inputmethod.latin;
package com.android.inputmethod.latin;


import com.android.inputmethod.latin.common.Constants;
import com.android.inputmethod.latin.common.NativeSuggestOptions;
import com.android.inputmethod.latin.common.NativeSuggestOptions;
import com.android.inputmethod.latin.define.DecoderSpecificConstants;
import com.android.inputmethod.latin.utils.JniUtils;
import com.android.inputmethod.latin.utils.JniUtils;


import java.util.Locale;
import java.util.Locale;
@@ -28,14 +28,15 @@ public final class DicTraverseSession {
    }
    }
    // Must be equal to MAX_RESULTS in native/jni/src/defines.h
    // Must be equal to MAX_RESULTS in native/jni/src/defines.h
    private static final int MAX_RESULTS = 18;
    private static final int MAX_RESULTS = 18;
    public final int[] mInputCodePoints = new int[Constants.DICTIONARY_MAX_WORD_LENGTH];
    public final int[] mInputCodePoints =
            new int[DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH];
    public final int[][] mPrevWordCodePointArrays =
    public final int[][] mPrevWordCodePointArrays =
            new int[Constants.MAX_PREV_WORD_COUNT_FOR_N_GRAM][];
            new int[DecoderSpecificConstants.MAX_PREV_WORD_COUNT_FOR_N_GRAM][];
    public final boolean[] mIsBeginningOfSentenceArray =
    public final boolean[] mIsBeginningOfSentenceArray =
            new boolean[Constants.MAX_PREV_WORD_COUNT_FOR_N_GRAM];
            new boolean[DecoderSpecificConstants.MAX_PREV_WORD_COUNT_FOR_N_GRAM];
    public final int[] mOutputSuggestionCount = new int[1];
    public final int[] mOutputSuggestionCount = new int[1];
    public final int[] mOutputCodePoints =
    public final int[] mOutputCodePoints =
            new int[Constants.DICTIONARY_MAX_WORD_LENGTH * MAX_RESULTS];
            new int[DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH * MAX_RESULTS];
    public final int[] mSpaceIndices = new int[MAX_RESULTS];
    public final int[] mSpaceIndices = new int[MAX_RESULTS];
    public final int[] mOutputScores = new int[MAX_RESULTS];
    public final int[] mOutputScores = new int[MAX_RESULTS];
    public final int[] mOutputTypes = new int[MAX_RESULTS];
    public final int[] mOutputTypes = new int[MAX_RESULTS];
+3 −2
Original line number Original line Diff line number Diff line
@@ -22,8 +22,8 @@ import android.util.Log;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.common.ComposedData;
import com.android.inputmethod.latin.common.ComposedData;
import com.android.inputmethod.latin.common.Constants;
import com.android.inputmethod.latin.common.FileUtils;
import com.android.inputmethod.latin.common.FileUtils;
import com.android.inputmethod.latin.define.DecoderSpecificConstants;
import com.android.inputmethod.latin.makedict.DictionaryHeader;
import com.android.inputmethod.latin.makedict.DictionaryHeader;
import com.android.inputmethod.latin.makedict.FormatSpec;
import com.android.inputmethod.latin.makedict.FormatSpec;
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
@@ -73,7 +73,8 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
    /**
    /**
     * The maximum length of a word in this dictionary.
     * The maximum length of a word in this dictionary.
     */
     */
    protected static final int MAX_WORD_LENGTH = Constants.DICTIONARY_MAX_WORD_LENGTH;
    protected static final int MAX_WORD_LENGTH =
            DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH;


    private static final int DICTIONARY_FORMAT_VERSION = FormatSpec.VERSION4;
    private static final int DICTIONARY_FORMAT_VERSION = FormatSpec.VERSION4;


Loading