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()); new FusionDictionary.DictionaryOptions());
if (null != dict) { if (null != dict) {
for (Word w : dict) { for (Word w : dict) {
// TODO: pass the shortcut targets newDict.add(w.mWord, w.mFrequency, w.mShortcutTargets, w.mBigrams);
newDict.add(w.mWord, w.mFrequency, null, w.mBigrams);
} }
} }

View File

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

View File

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