Merge "Make the dictionary iterator shortcut-aware (B4)"

main
Jean Chalard 2012-01-05 21:36:46 -08:00 committed by Android (Google) Code Review
commit 69f94e1983
3 changed files with 8 additions and 5 deletions

View File

@ -1003,8 +1003,7 @@ public class BinaryDictInputOutput {
new FusionDictionary.DictionaryOptions());
if (null != dict) {
for (Word w : dict) {
// TODO: pass the shortcut targets
newDict.add(w.mWord, w.mFrequency, null, w.mBigrams);
newDict.add(w.mWord, w.mFrequency, w.mShortcutTargets, w.mBigrams);
}
}

View File

@ -592,8 +592,7 @@ public class FusionDictionary implements Iterable<Word> {
}
if (currentGroup.mFrequency >= 0)
return new Word(mCurrentString.toString(), currentGroup.mFrequency,
// TODO: pass the shortcut targets here
currentGroup.mBigrams);
currentGroup.mShortcutTargets, currentGroup.mBigrams);
} else {
mPositions.removeLast();
currentPos = mPositions.getLast();

View File

@ -28,11 +28,15 @@ import java.util.ArrayList;
public class Word implements Comparable<Word> {
final String mWord;
final int mFrequency;
final ArrayList<WeightedString> mShortcutTargets;
final ArrayList<WeightedString> mBigrams;
public Word(String word, int frequency, ArrayList<WeightedString> bigrams) {
public Word(final String word, final int frequency,
final ArrayList<WeightedString> shortcutTargets,
final ArrayList<WeightedString> bigrams) {
mWord = word;
mFrequency = frequency;
mShortcutTargets = shortcutTargets;
mBigrams = bigrams;
}
@ -60,6 +64,7 @@ public class Word implements Comparable<Word> {
if (!(o instanceof Word)) return false;
Word w = (Word)o;
return mFrequency == w.mFrequency && mWord.equals(w.mWord)
&& mShortcutTargets.equals(w.mShortcutTargets)
&& mBigrams.equals(w.mBigrams);
}
}