diff options
author | 2014-03-06 18:53:06 +0900 | |
---|---|---|
committer | 2014-03-06 18:53:06 +0900 | |
commit | 516f86815ddec465e3d3ff59540d26913b05236f (patch) | |
tree | fbac6cd095d1aea18b6ebb8f5e42bbfa33c7e1e6 /java/src/com/android/inputmethod/latin/makedict/WeightedString.java | |
parent | de36b47d29b7d6bdfb448a97bef2dcc3f5649205 (diff) | |
download | latinime-516f86815ddec465e3d3ff59540d26913b05236f.tar.gz latinime-516f86815ddec465e3d3ff59540d26913b05236f.tar.xz latinime-516f86815ddec465e3d3ff59540d26913b05236f.zip |
Separate WeightedString from FusionDictionary.
Bug: 8187060
Change-Id: I40c1dafca3eb52244c64fdb4c1db30a56385d678
Diffstat (limited to 'java/src/com/android/inputmethod/latin/makedict/WeightedString.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/WeightedString.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/WeightedString.java b/java/src/com/android/inputmethod/latin/makedict/WeightedString.java new file mode 100644 index 000000000..f6782df9e --- /dev/null +++ b/java/src/com/android/inputmethod/latin/makedict/WeightedString.java @@ -0,0 +1,62 @@ +/* + * 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.makedict; + +import com.android.inputmethod.annotations.UsedForTesting; + +import java.util.Arrays; + +/** + * A string with a probability. + * + * This represents an "attribute", that is either a bigram or a shortcut. + */ +public final class WeightedString { + public final String mWord; + public ProbabilityInfo mProbabilityInfo; + + public WeightedString(final String word, final int probability) { + this(word, new ProbabilityInfo(probability)); + } + + public WeightedString(final String word, final ProbabilityInfo probabilityInfo) { + mWord = word; + mProbabilityInfo = probabilityInfo; + } + + @UsedForTesting + public int getProbability() { + return mProbabilityInfo.mProbability; + } + + public void setProbability(final int probability) { + mProbabilityInfo = new ProbabilityInfo(probability); + } + + @Override + public int hashCode() { + return Arrays.hashCode(new Object[] { mWord, mProbabilityInfo}); + } + + @Override + public boolean equals(Object o) { + if (o == this) return true; + if (!(o instanceof WeightedString)) return false; + final WeightedString w = (WeightedString)o; + return mWord.equals(w.mWord) && mProbabilityInfo.equals(w.mProbabilityInfo); + } +}
\ No newline at end of file |