diff options
author | 2012-10-29 17:21:50 +0900 | |
---|---|---|
committer | 2012-10-29 18:08:50 +0900 | |
commit | e5b68fb51d6de3d007c3b6ada31386a7b329c812 (patch) | |
tree | 87b4fb932fec0e1813b75660b31178d79a97c951 /tools/dicttool/src | |
parent | cfbfb1c50a18234c5415a9897f62b0d456036885 (diff) | |
download | latinime-e5b68fb51d6de3d007c3b6ada31386a7b329c812.tar.gz latinime-e5b68fb51d6de3d007c3b6ada31386a7b329c812.tar.xz latinime-e5b68fb51d6de3d007c3b6ada31386a7b329c812.zip |
Accept comments in the combined file format
Change-Id: I17b745281b8b7b1922e1c2d3717986e9bb11aa0b
Diffstat (limited to 'tools/dicttool/src')
-rw-r--r-- | tools/dicttool/src/com/android/inputmethod/latin/dicttool/CombinedInputOutput.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/CombinedInputOutput.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/CombinedInputOutput.java index cd04d18bb..c295eb384 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/CombinedInputOutput.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/CombinedInputOutput.java @@ -52,6 +52,7 @@ public class CombinedInputOutput { private static final String OPTIONS_TAG = "options"; private static final String GERMAN_UMLAUT_PROCESSING_OPTION = "german_umlaut_processing"; private static final String FRENCH_LIGATURE_PROCESSING_OPTION = "french_ligature_processing"; + private static final String COMMENT_LINE_STARTER = "#"; /** * Basic test to find out whether the file is in the combined format or not. @@ -65,7 +66,10 @@ public class CombinedInputOutput { BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(new File(filename))); - final String firstLine = reader.readLine(); + String firstLine = reader.readLine(); + while (firstLine.startsWith(COMMENT_LINE_STARTER)) { + firstLine = reader.readLine(); + } return firstLine.matches("^" + DICTIONARY_TAG + "=[^:]+(:[^=]+=[^:]+)*"); } catch (FileNotFoundException e) { return false; @@ -94,7 +98,10 @@ public class CombinedInputOutput { public static FusionDictionary readDictionaryCombined(final InputStream source) throws IOException { final BufferedReader reader = new BufferedReader(new InputStreamReader(source, "UTF-8")); - final String headerLine = reader.readLine(); + String headerLine = reader.readLine(); + while (headerLine.startsWith(COMMENT_LINE_STARTER)) { + headerLine = reader.readLine(); + } final String header[] = headerLine.split(","); final HashMap<String, String> attributes = new HashMap<String, String>(); for (String item : header) { @@ -120,6 +127,7 @@ public class CombinedInputOutput { ArrayList<WeightedString> bigrams = new ArrayList<WeightedString>(); ArrayList<WeightedString> shortcuts = new ArrayList<WeightedString>(); while (null != (line = reader.readLine())) { + if (line.startsWith(COMMENT_LINE_STARTER)) continue; final String args[] = line.trim().split(","); if (args[0].matches(WORD_TAG + "=.*")) { if (null != word) { |