Make the dictionary iterator shortcut-aware (B4)

Change-Id: I529dff4a50276d1a4f4896c66d1aa35296b21000
This commit is contained in:
Jean Chalard 2011-12-26 19:04:35 +09:00
parent eec2e51e2c
commit aa91871030
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);
}
}