am 7b9b0950: Move LanguageModelParams class to utility package
* commit '7b9b09509083af20019828972f9558336ec7da7a': Move LanguageModelParams class to utility packagemain
commit
ff4aab46b0
|
@ -25,6 +25,7 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
|||
import com.android.inputmethod.latin.settings.NativeSuggestOptions;
|
||||
import com.android.inputmethod.latin.utils.CollectionUtils;
|
||||
import com.android.inputmethod.latin.utils.JniUtils;
|
||||
import com.android.inputmethod.latin.utils.LanguageModelParam;
|
||||
import com.android.inputmethod.latin.utils.StringUtils;
|
||||
import com.android.inputmethod.latin.utils.UnigramProperty;
|
||||
|
||||
|
@ -364,51 +365,6 @@ public final class BinaryDictionary extends Dictionary {
|
|||
removeBigramWordsNative(mNativeDict, codePoints0, codePoints1);
|
||||
}
|
||||
|
||||
public static class LanguageModelParam {
|
||||
public final String mTargetWord;
|
||||
public final int[] mWord0;
|
||||
public final int[] mWord1;
|
||||
// TODO: this needs to be a list of shortcuts
|
||||
public final int[] mShortcutTarget;
|
||||
public final int mUnigramProbability;
|
||||
public final int mBigramProbability;
|
||||
public final int mShortcutProbability;
|
||||
public final boolean mIsNotAWord;
|
||||
public final boolean mIsBlacklisted;
|
||||
public final int mTimestamp;
|
||||
|
||||
// Constructor for unigram. TODO: support shortcuts
|
||||
public LanguageModelParam(final String word, final int unigramProbability,
|
||||
final int timestamp) {
|
||||
mTargetWord = word;
|
||||
mWord0 = null;
|
||||
mWord1 = StringUtils.toCodePointArray(word);
|
||||
mShortcutTarget = null;
|
||||
mUnigramProbability = unigramProbability;
|
||||
mBigramProbability = NOT_A_PROBABILITY;
|
||||
mShortcutProbability = NOT_A_PROBABILITY;
|
||||
mIsNotAWord = false;
|
||||
mIsBlacklisted = false;
|
||||
mTimestamp = timestamp;
|
||||
}
|
||||
|
||||
// Constructor for unigram and bigram.
|
||||
public LanguageModelParam(final String word0, final String word1,
|
||||
final int unigramProbability, final int bigramProbability,
|
||||
final int timestamp) {
|
||||
mTargetWord = word1;
|
||||
mWord0 = StringUtils.toCodePointArray(word0);
|
||||
mWord1 = StringUtils.toCodePointArray(word1);
|
||||
mShortcutTarget = null;
|
||||
mUnigramProbability = unigramProbability;
|
||||
mBigramProbability = bigramProbability;
|
||||
mShortcutProbability = NOT_A_PROBABILITY;
|
||||
mIsNotAWord = false;
|
||||
mIsBlacklisted = false;
|
||||
mTimestamp = timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
public void addMultipleDictionaryEntries(final LanguageModelParam[] languageModelParams) {
|
||||
if (!isValidDictionary()) return;
|
||||
int processedParamCount = 0;
|
||||
|
|
|
@ -21,12 +21,12 @@ import android.util.Log;
|
|||
|
||||
import com.android.inputmethod.annotations.UsedForTesting;
|
||||
import com.android.inputmethod.keyboard.ProximityInfo;
|
||||
import com.android.inputmethod.latin.BinaryDictionary.LanguageModelParam;
|
||||
import com.android.inputmethod.latin.makedict.FormatSpec;
|
||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||
import com.android.inputmethod.latin.utils.AsyncResultHolder;
|
||||
import com.android.inputmethod.latin.utils.CollectionUtils;
|
||||
import com.android.inputmethod.latin.utils.FileUtils;
|
||||
import com.android.inputmethod.latin.utils.LanguageModelParam;
|
||||
import com.android.inputmethod.latin.utils.PrioritizedSerialExecutor;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
@ -20,13 +20,13 @@ import android.content.Context;
|
|||
import android.util.Log;
|
||||
|
||||
import com.android.inputmethod.annotations.UsedForTesting;
|
||||
import com.android.inputmethod.latin.BinaryDictionary.LanguageModelParam;
|
||||
import com.android.inputmethod.latin.Constants;
|
||||
import com.android.inputmethod.latin.Dictionary;
|
||||
import com.android.inputmethod.latin.ExpandableBinaryDictionary;
|
||||
import com.android.inputmethod.latin.makedict.DictDecoder;
|
||||
import com.android.inputmethod.latin.makedict.FormatSpec;
|
||||
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
|
||||
import com.android.inputmethod.latin.utils.LanguageModelParam;
|
||||
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils;
|
||||
import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.OnAddWordListener;
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ package com.android.inputmethod.latin.personalization;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.inputmethod.latin.BinaryDictionary.LanguageModelParam;
|
||||
import com.android.inputmethod.latin.ExpandableBinaryDictionary;
|
||||
import com.android.inputmethod.latin.utils.LanguageModelParam;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright (C) 2014 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.utils;
|
||||
|
||||
import com.android.inputmethod.latin.Dictionary;
|
||||
|
||||
public class LanguageModelParam {
|
||||
public final String mTargetWord;
|
||||
public final int[] mWord0;
|
||||
public final int[] mWord1;
|
||||
// TODO: this needs to be a list of shortcuts
|
||||
public final int[] mShortcutTarget;
|
||||
public final int mUnigramProbability;
|
||||
public final int mBigramProbability;
|
||||
public final int mShortcutProbability;
|
||||
public final boolean mIsNotAWord;
|
||||
public final boolean mIsBlacklisted;
|
||||
// Time stamp in seconds.
|
||||
public final int mTimestamp;
|
||||
|
||||
// Constructor for unigram. TODO: support shortcuts
|
||||
public LanguageModelParam(final String word, final int unigramProbability,
|
||||
final int timestamp) {
|
||||
mTargetWord = word;
|
||||
mWord0 = null;
|
||||
mWord1 = StringUtils.toCodePointArray(word);
|
||||
mShortcutTarget = null;
|
||||
mUnigramProbability = unigramProbability;
|
||||
mBigramProbability = Dictionary.NOT_A_PROBABILITY;
|
||||
mShortcutProbability = Dictionary.NOT_A_PROBABILITY;
|
||||
mIsNotAWord = false;
|
||||
mIsBlacklisted = false;
|
||||
mTimestamp = timestamp;
|
||||
}
|
||||
|
||||
// Constructor for unigram and bigram.
|
||||
public LanguageModelParam(final String word0, final String word1,
|
||||
final int unigramProbability, final int bigramProbability,
|
||||
final int timestamp) {
|
||||
mTargetWord = word1;
|
||||
mWord0 = StringUtils.toCodePointArray(word0);
|
||||
mWord1 = StringUtils.toCodePointArray(word1);
|
||||
mShortcutTarget = null;
|
||||
mUnigramProbability = unigramProbability;
|
||||
mBigramProbability = bigramProbability;
|
||||
mShortcutProbability = Dictionary.NOT_A_PROBABILITY;
|
||||
mIsNotAWord = false;
|
||||
mIsBlacklisted = false;
|
||||
mTimestamp = timestamp;
|
||||
}
|
||||
}
|
|
@ -21,11 +21,11 @@ import android.test.suitebuilder.annotation.LargeTest;
|
|||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.inputmethod.latin.BinaryDictionary.LanguageModelParam;
|
||||
import com.android.inputmethod.latin.makedict.CodePointUtils;
|
||||
import com.android.inputmethod.latin.makedict.FormatSpec;
|
||||
import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString;
|
||||
import com.android.inputmethod.latin.utils.FileUtils;
|
||||
import com.android.inputmethod.latin.utils.LanguageModelParam;
|
||||
import com.android.inputmethod.latin.utils.UnigramProperty;
|
||||
|
||||
import java.io.File;
|
||||
|
|
Loading…
Reference in New Issue