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

Commit aadfef6f authored by Mohammadinamul Sheik's avatar Mohammadinamul Sheik Committed by Android (Google) Code Review
Browse files

Merge "Move decoder specific constants to DecoderSpecificConstants.java"

parents d6a8adcb 0f7d881d
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -173,15 +173,6 @@ public final class Constants {
    // right for this.
    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.
    public static final int LONG_PRESS_MILLISECONDS = 200;
    // TODO: Set this value appropriately.
+30 −0
Original line number 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 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.InputPointers;
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.FormatSpec;
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 ArrayList<SuggestedWordInfo> suggestions = new ArrayList<>();
        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;
            while (len < Constants.DICTIONARY_MAX_WORD_LENGTH
            while (len < DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH
                    && session.mOutputCodePoints[start + len] != 0) {
                ++len;
            }
@@ -390,7 +391,7 @@ public final class BinaryDictionary extends Dictionary {
            return null;
        }
        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 int[] outProbabilityInfo =
                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.
     */
    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 int nextToken = getNextWordNative(mNativeDict, token, codePoints,
                isBeginningOfSentence);
+6 −5
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package com.android.inputmethod.latin;

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

import java.util.Locale;
@@ -28,14 +28,15 @@ public final class DicTraverseSession {
    }
    // Must be equal to MAX_RESULTS in native/jni/src/defines.h
    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 =
            new int[Constants.MAX_PREV_WORD_COUNT_FOR_N_GRAM][];
            new int[DecoderSpecificConstants.MAX_PREV_WORD_COUNT_FOR_N_GRAM][];
    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[] 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[] mOutputScores = new int[MAX_RESULTS];
    public final int[] mOutputTypes = new int[MAX_RESULTS];
+3 −2
Original line number Diff line number Diff line
@@ -22,8 +22,8 @@ import android.util.Log;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
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.define.DecoderSpecificConstants;
import com.android.inputmethod.latin.makedict.DictionaryHeader;
import com.android.inputmethod.latin.makedict.FormatSpec;
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.
     */
    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;

Loading