aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-12-26 19:57:03 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-12-26 19:57:03 -0800
commitedd1018bae1cef83cfb008e9838d2c289c5306d0 (patch)
treeb26d2064f4b55248b66b1261fc044db4bf64fe6c
parentf2a12e5ad35ff59cd58c6422560218e21c27ef76 (diff)
parent0236c892e6e2a1c313f26380b5d23269600d0c2f (diff)
downloadlatinime-edd1018bae1cef83cfb008e9838d2c289c5306d0.tar.gz
latinime-edd1018bae1cef83cfb008e9838d2c289c5306d0.tar.xz
latinime-edd1018bae1cef83cfb008e9838d2c289c5306d0.zip
am 0236c892: Merge "Fix a bug where attributes would have the wrong freq (B0)"
* commit '0236c892e6e2a1c313f26380b5d23269600d0c2f': Fix a bug where attributes would have the wrong freq (B0)
-rw-r--r--tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java b/tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java
index 35a7b51d6..1535eb0b8 100644
--- a/tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java
+++ b/tools/makedict/src/com/android/inputmethod/latin/XmlDictInputOutput.java
@@ -123,6 +123,12 @@ public class XmlDictInputOutput {
private final static String BIGRAM_W2_ATTRIBUTE = "w2";
private final static String BIGRAM_FREQ_ATTRIBUTE = "p";
+ // 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 XML_TO_MEMORY_RATIO = XML_MAX / MEMORY_MAX;
+
String mW1;
final HashMap<String, ArrayList<WeightedString>> mBigramsMap;
@@ -138,7 +144,7 @@ public class XmlDictInputOutput {
} else if (BIGRAM_W2_TAG.equals(localName)) {
String w2 = attrs.getValue(uri, BIGRAM_W2_ATTRIBUTE);
int freq = Integer.parseInt(attrs.getValue(uri, BIGRAM_FREQ_ATTRIBUTE));
- WeightedString bigram = new WeightedString(w2, freq / 8);
+ WeightedString bigram = new WeightedString(w2, freq / XML_TO_MEMORY_RATIO);
ArrayList<WeightedString> bigramList = mBigramsMap.get(mW1);
if (null == bigramList) bigramList = new ArrayList<WeightedString>();
bigramList.add(bigram);