summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-04-24 16:08:21 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-04-24 16:08:21 -0700
commit782884aef34a060c280f7be640e8c2e715750ce8 (patch)
tree6efb2229a6e96df237ae9dcc31f32db69f07aff8
parente007ff4cfa446aebe2c3d5c2e04f76b4258c5b5f (diff)
parent6fdf92fb262863b901231bed5ef9aaf11eee69f2 (diff)
downloadandroid_development-782884aef34a060c280f7be640e8c2e715750ce8.tar.gz
android_development-782884aef34a060c280f7be640e8c2e715750ce8.tar.bz2
android_development-782884aef34a060c280f7be640e8c2e715750ce8.zip
Merge change 556 into donut
* changes: Fixed a bug in XML parser handler where some words were being split in two. Fixes #1812655.
-rwxr-xr-xtools/makedict/src/com/android/tools/dict/MakeBinaryDictionary.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/tools/makedict/src/com/android/tools/dict/MakeBinaryDictionary.java b/tools/makedict/src/com/android/tools/dict/MakeBinaryDictionary.java
index 8a8a677da..77a6401af 100755
--- a/tools/makedict/src/com/android/tools/dict/MakeBinaryDictionary.java
+++ b/tools/makedict/src/com/android/tools/dict/MakeBinaryDictionary.java
@@ -96,6 +96,7 @@ public class MakeBinaryDictionary {
parser.parse(new File(filename), new DefaultHandler() {
boolean inWord;
int freq;
+ StringBuilder wordBuilder = new StringBuilder(48);
@Override
public void startElement(String uri, String localName,
@@ -103,6 +104,7 @@ public class MakeBinaryDictionary {
if (qName.equals("w")) {
inWord = true;
freq = Integer.parseInt(attributes.getValue(0));
+ wordBuilder.setLength(0);
}
}
@@ -110,18 +112,19 @@ public class MakeBinaryDictionary {
public void characters(char[] data, int offset, int length) {
// Ignore other whitespace
if (!inWord) return;
-
- // Ignore one letter words
- if (length < 2) return;
- mWordCount++;
- String word = new String(data, offset, length);
- addWordTop(word, freq);
+ wordBuilder.append(data, offset, length);
}
@Override
public void endElement(String uri, String localName,
String qName) {
- if (qName.equals("w")) inWord = false;
+ if (qName.equals("w")) {
+ if (wordBuilder.length() > 1) {
+ addWordTop(wordBuilder.toString(), freq);
+ mWordCount++;
+ }
+ inWord = false;
+ }
}
});
} catch (Exception ioe) {
@@ -145,7 +148,6 @@ public class MakeBinaryDictionary {
private void addWordTop(String word, int occur) {
if (occur > 255) occur = 255;
-
char firstChar = word.charAt(0);
int index = indexOf(roots, firstChar);
if (index == -1) {