aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-05-11 04:13:53 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-11 04:13:53 -0700
commite1c75a42c293a611ae5e12f93eefcb455d87d706 (patch)
tree598f78d72fc00eeab514f0e2946c85f66a35c408
parent0dee42e4d4d937921385c2c8380bb59760391b01 (diff)
parentad0233fa02985e597054bc50726a412fd8fff371 (diff)
downloadlatinime-e1c75a42c293a611ae5e12f93eefcb455d87d706.tar.gz
latinime-e1c75a42c293a611ae5e12f93eefcb455d87d706.tar.xz
latinime-e1c75a42c293a611ae5e12f93eefcb455d87d706.zip
am ad0233fa: Merge "Refactor a method" into jb-dev
* commit 'ad0233fa02985e597054bc50726a412fd8fff371': Refactor a method
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java24
-rw-r--r--tools/makedict/src/com/android/inputmethod/latin/makedict/XmlDictInputOutput.java2
2 files changed, 15 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
index d82d503c4..4845a33a5 100644
--- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
+++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
@@ -722,15 +722,16 @@ public class BinaryDictInputOutput {
}
/**
- * Makes the flag value for an attribute.
+ * Makes the flag value for a bigram.
*
- * @param more whether there are more attributes after this one.
- * @param offset the offset of the attribute.
- * @param frequency the frequency of the attribute, 0..15
+ * @param more whether there are more bigrams after this one.
+ * @param offset the offset of the bigram.
+ * @param bigramFrequency the frequency of the bigram, 0..15.
+ * @param unigramFrequency the unigram frequency of the same word.
* @return the flags
*/
- private static final int makeAttributeFlags(final boolean more, final int offset,
- final int frequency) {
+ private static final int makeBigramFlags(final boolean more, final int offset,
+ final int bigramFrequency, final int unigramFrequency) {
int bigramFlags = (more ? FLAG_ATTRIBUTE_HAS_NEXT : 0)
+ (offset < 0 ? FLAG_ATTRIBUTE_OFFSET_NEGATIVE : 0);
switch (getByteSize(offset)) {
@@ -746,7 +747,7 @@ public class BinaryDictInputOutput {
default:
throw new RuntimeException("Strange offset size");
}
- bigramFlags += frequency & FLAG_ATTRIBUTE_FREQUENCY;
+ bigramFlags += bigramFrequency & FLAG_ATTRIBUTE_FREQUENCY;
return bigramFlags;
}
@@ -854,11 +855,14 @@ public class BinaryDictInputOutput {
final Iterator bigramIterator = group.mBigrams.iterator();
while (bigramIterator.hasNext()) {
final WeightedString bigram = (WeightedString)bigramIterator.next();
- final int addressOfBigram = findAddressOfWord(dict, bigram.mWord);
+ final CharGroup target =
+ FusionDictionary.findWordInTree(dict.mRoot, bigram.mWord);
+ final int addressOfBigram = target.mCachedAddress;
+ final int unigramFrequencyForThisWord = target.mFrequency;
++groupAddress;
final int offset = addressOfBigram - groupAddress;
- int bigramFlags = makeAttributeFlags(bigramIterator.hasNext(), offset,
- bigram.mFrequency);
+ int bigramFlags = makeBigramFlags(bigramIterator.hasNext(), offset,
+ bigram.mFrequency, unigramFrequencyForThisWord);
buffer[index++] = (byte)bigramFlags;
final int bigramShift = writeVariableAddress(buffer, index, Math.abs(offset));
index += bigramShift;
diff --git a/tools/makedict/src/com/android/inputmethod/latin/makedict/XmlDictInputOutput.java b/tools/makedict/src/com/android/inputmethod/latin/makedict/XmlDictInputOutput.java
index d86719a1d..52f124dfb 100644
--- a/tools/makedict/src/com/android/inputmethod/latin/makedict/XmlDictInputOutput.java
+++ b/tools/makedict/src/com/android/inputmethod/latin/makedict/XmlDictInputOutput.java
@@ -154,7 +154,7 @@ public class XmlDictInputOutput {
// In this version of the XML file, the bigram frequency is given as an int 0..XML_MAX
private final static int XML_MAX = 256;
// In memory and in the binary dictionary the bigram frequency is 0..MEMORY_MAX
- private final static int MEMORY_MAX = 16;
+ private final static int MEMORY_MAX = 256;
private final static int XML_TO_MEMORY_RATIO = XML_MAX / MEMORY_MAX;
private String mSrc;