diff options
Diffstat (limited to 'tools')
11 files changed, 189 insertions, 22 deletions
diff --git a/tools/dicttool/Android.mk b/tools/dicttool/Android.mk index df8cb1030..b0b47af00 100644 --- a/tools/dicttool/Android.mk +++ b/tools/dicttool/Android.mk @@ -26,7 +26,6 @@ LOCAL_SRC_FILES := $(LOCAL_TOOL_SRC_FILES) \ LOCAL_JAR_MANIFEST := etc/manifest.txt LOCAL_MODULE := dicttool_aosp LOCAL_JAVA_LIBRARIES := junit -LOCAL_MODULE_TAGS := eng include $(BUILD_HOST_JAVA_LIBRARY) include $(LOCAL_PATH)/etc/Android.mk diff --git a/tools/dicttool/etc/Android.mk b/tools/dicttool/etc/Android.mk index 8952827ab..0c611b7e9 100644 --- a/tools/dicttool/etc/Android.mk +++ b/tools/dicttool/etc/Android.mk @@ -15,6 +15,5 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE_TAGS := eng LOCAL_PREBUILT_EXECUTABLES := dicttool_aosp makedict_aosp include $(BUILD_HOST_PREBUILT) diff --git a/tools/dicttool/src/android/inputmethod/latin/dicttool/DictionaryMaker.java b/tools/dicttool/src/android/inputmethod/latin/dicttool/DictionaryMaker.java index 25e1740cb..fbfc1dabb 100644 --- a/tools/dicttool/src/android/inputmethod/latin/dicttool/DictionaryMaker.java +++ b/tools/dicttool/src/android/inputmethod/latin/dicttool/DictionaryMaker.java @@ -27,7 +27,8 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; -import java.io.RandomAccessFile; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; import java.util.Arrays; import java.util.LinkedList; @@ -238,8 +239,23 @@ public class DictionaryMaker { */ private static FusionDictionary readBinaryFile(final String binaryFilename) throws FileNotFoundException, IOException, UnsupportedFormatException { - final RandomAccessFile inputFile = new RandomAccessFile(binaryFilename, "r"); - return BinaryDictInputOutput.readDictionaryBinary(inputFile, null); + FileInputStream inStream = null; + + try { + final File file = new File(binaryFilename); + inStream = new FileInputStream(file); + final ByteBuffer buffer = inStream.getChannel().map( + FileChannel.MapMode.READ_ONLY, 0, file.length()); + return BinaryDictInputOutput.readDictionaryBinary(buffer, null); + } finally { + if (inStream != null) { + try { + inStream.close(); + } catch (IOException e) { + // do nothing + } + } + } } /** diff --git a/tools/dicttool/src/android/inputmethod/latin/dicttool/XmlDictInputOutput.java b/tools/dicttool/src/android/inputmethod/latin/dicttool/XmlDictInputOutput.java index 9ce8c4934..c31cd724a 100644 --- a/tools/dicttool/src/android/inputmethod/latin/dicttool/XmlDictInputOutput.java +++ b/tools/dicttool/src/android/inputmethod/latin/dicttool/XmlDictInputOutput.java @@ -50,6 +50,7 @@ public class XmlDictInputOutput { private static final String SHORTCUT_TAG = "shortcut"; private static final String FREQUENCY_ATTR = "f"; private static final String WORD_ATTR = "word"; + private static final String NOT_A_WORD_ATTR = "not_a_word"; private static final int SHORTCUT_ONLY_DEFAULT_FREQ = 1; @@ -92,7 +93,7 @@ public class XmlDictInputOutput { final FusionDictionary dict = mDictionary; for (final String shortcutOnly : mShortcutsMap.keySet()) { if (dict.hasWord(shortcutOnly)) continue; - dict.add(shortcutOnly, 0, mShortcutsMap.get(shortcutOnly)); + dict.add(shortcutOnly, 0, mShortcutsMap.get(shortcutOnly), true /* isNotAWord */); } mDictionary = null; mShortcutsMap.clear(); @@ -144,7 +145,7 @@ public class XmlDictInputOutput { @Override public void endElement(String uri, String localName, String qName) { if (WORD == mState) { - mDictionary.add(mWord, mFreq, mShortcutsMap.get(mWord)); + mDictionary.add(mWord, mFreq, mShortcutsMap.get(mWord), false /* isNotAWord */); mState = START; } } @@ -345,7 +346,8 @@ public class XmlDictInputOutput { destination.write("<!-- Warning: there is no code to read this format yet. -->\n"); for (Word word : set) { destination.write(" <" + WORD_TAG + " " + WORD_ATTR + "=\"" + word.mWord + "\" " - + FREQUENCY_ATTR + "=\"" + word.mFrequency + "\">"); + + FREQUENCY_ATTR + "=\"" + word.mFrequency + + (word.mIsNotAWord ? "\" " + NOT_A_WORD_ATTR + "=\"true" : "") + "\">"); if (null != word.mShortcutTargets) { destination.write("\n"); for (WeightedString target : word.mShortcutTargets) { diff --git a/tools/dicttool/tests/com/android/inputmethod/latin/makedict/BinaryDictInputOutputTest.java b/tools/dicttool/tests/com/android/inputmethod/latin/makedict/BinaryDictInputOutputTest.java index 24042f120..88589b815 100644 --- a/tools/dicttool/tests/com/android/inputmethod/latin/makedict/BinaryDictInputOutputTest.java +++ b/tools/dicttool/tests/com/android/inputmethod/latin/makedict/BinaryDictInputOutputTest.java @@ -43,11 +43,11 @@ public class BinaryDictInputOutputTest extends TestCase { final FusionDictionary dict = new FusionDictionary(new Node(), new DictionaryOptions(new HashMap<String, String>(), false /* germanUmlautProcessing */, false /* frenchLigatureProcessing */)); - dict.add("foo", 1, null); - dict.add("fta", 1, null); - dict.add("ftb", 1, null); - dict.add("bar", 1, null); - dict.add("fool", 1, null); + dict.add("foo", 1, null, false /* isNotAWord */); + dict.add("fta", 1, null, false /* isNotAWord */); + dict.add("ftb", 1, null, false /* isNotAWord */); + dict.add("bar", 1, null, false /* isNotAWord */); + dict.add("fool", 1, null, false /* isNotAWord */); final ArrayList<Node> result = BinaryDictInputOutput.flattenTree(dict.mRoot); assertEquals(4, result.size()); while (!result.isEmpty()) { diff --git a/tools/maketext/Android.mk b/tools/maketext/Android.mk index 98731b718..77914cae6 100644 --- a/tools/maketext/Android.mk +++ b/tools/maketext/Android.mk @@ -19,7 +19,6 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES += $(call all-java-files-under,src) LOCAL_JAR_MANIFEST := etc/manifest.txt LOCAL_JAVA_RESOURCE_DIRS := res -LOCAL_MODULE_TAGS := eng LOCAL_MODULE := maketext include $(BUILD_HOST_JAVA_LIBRARY) diff --git a/tools/maketext/etc/Android.mk b/tools/maketext/etc/Android.mk index 4fa194bcd..475676b3a 100644 --- a/tools/maketext/etc/Android.mk +++ b/tools/maketext/etc/Android.mk @@ -15,7 +15,6 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE_TAGS := eng - LOCAL_PREBUILT_EXECUTABLES := maketext + include $(BUILD_HOST_PREBUILT) diff --git a/tools/maketext/res/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.tmpl b/tools/maketext/res/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.tmpl index f6c84eaf2..774094cd7 100644 --- a/tools/maketext/res/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.tmpl +++ b/tools/maketext/res/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.tmpl @@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard.internal; import android.content.Context; import android.content.res.Resources; +import com.android.inputmethod.latin.CollectionUtils; import com.android.inputmethod.latin.R; import java.util.HashMap; @@ -45,14 +46,12 @@ import java.util.HashMap; */ public final class KeyboardTextsSet { // Language to texts map. - private static final HashMap<String, String[]> sLocaleToTextsMap = - new HashMap<String, String[]>(); - private static final HashMap<String, Integer> sNameToIdsMap = - new HashMap<String, Integer>(); + private static final HashMap<String, String[]> sLocaleToTextsMap = CollectionUtils.newHashMap(); + private static final HashMap<String, Integer> sNameToIdsMap = CollectionUtils.newHashMap(); private String[] mTexts; // Resource name to text map. - private HashMap<String, String> mResourceNameToTextsMap = new HashMap<String, String>(); + private HashMap<String, String> mResourceNameToTextsMap = CollectionUtils.newHashMap(); public void setLanguage(final String language) { mTexts = sLocaleToTextsMap.get(language); diff --git a/tools/maketext/res/values-eo/donottranslate-more-keys.xml b/tools/maketext/res/values-eo/donottranslate-more-keys.xml new file mode 100644 index 000000000..e929869e2 --- /dev/null +++ b/tools/maketext/res/values-eo/donottranslate-more-keys.xml @@ -0,0 +1,146 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + U+00E6: "æ" LATIN SMALL LETTER AE + U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + U+0103: "ă" LATIN SMALL LETTER A WITH BREVE + U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK + U+00AA: "ª" FEMININE ORDINAL INDICATOR --> + <string name="more_keys_for_a">á,à,â,ä,æ,ã,å,ā,ă,ą,ª</string> + <!-- U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + U+011B: "ě" LATIN SMALL LETTER E WITH CARON + U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + U+0113: "ē" LATIN SMALL LETTER E WITH MACRON --> + <string name="more_keys_for_e">é,ě,è,ê,ë,ę,ė,ē</string> + <!-- U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + U+0129: "ĩ" LATIN SMALL LETTER I WITH TILDE + U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + U+0131: "ı" LATIN SMALL LETTER DOTLESS I + U+0133: "ij" LATIN SMALL LIGATURE IJ --> + <string name="more_keys_for_i">í,î,ï,ĩ,ì,į,ī,ı,ij</string> + <!-- U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + U+0153: "œ" LATIN SMALL LIGATURE OE + U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + U+0151: "ő" LATIN SMALL LETTER O WITH DOUBLE ACUTE + U+00BA: "º" MASCULINE ORDINAL INDICATOR --> + <string name="more_keys_for_o">ó,ö,ô,ò,õ,œ,ø,ō,ő,º</string> + <!-- U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + U+016F: "ů" LATIN SMALL LETTER U WITH RING ABOVE + U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + U+0169: "ũ" LATIN SMALL LETTER U WITH TILDE + U+0171: "ű" LATIN SMALL LETTER U WITH DOUBLE ACUTE + U+0173: "ų" LATIN SMALL LETTER U WITH OGONEK + U+00B5: "µ" MICRO SIGN --> + <string name="more_keys_for_u">ú,ů,û,ü,ù,ū,ũ,ű,ų,µ</string> + <!-- U+00DF: "ß" LATIN SMALL LETTER SHARP S + U+0161: "š" LATIN SMALL LETTER S WITH CARON + U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + U+0219: "ș" LATIN SMALL LETTER S WITH COMMA BELOW + U+015F: "ş" LATIN SMALL LETTER S WITH CEDILLA --> + <string name="more_keys_for_s">ß,š,ś,ș,ş</string> + <!-- U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + U+0146: "ņ" LATIN SMALL LETTER N WITH CEDILLA + U+0148: "ň" LATIN SMALL LETTER N WITH CARON + U+0149: "ʼn" LATIN SMALL LETTER N PRECEDED BY APOSTROPHE + U+014B: "ŋ" LATIN SMALL LETTER ENG --> + <string name="more_keys_for_n">ñ,ń,ņ,ň,ʼn,ŋ</string> + <!-- U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + U+010D: "č" LATIN SMALL LETTER C WITH CARON + U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + U+010B: "ċ" LATIN SMALL LETTER C WITH DOT ABOVE --> + <string name="more_keys_for_c">ć,č,ç,ċ</string> + <!-- U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + U+0177: "ŷ" LATIN SMALL LETTER Y WITH CIRCUMFLEX + U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + U+00FE: "þ" LATIN SMALL LETTER THORN --> + <string name="more_keys_for_y">y,ý,ŷ,ÿ,þ</string> + <!-- U+00F0: "ð" LATIN SMALL LETTER ETH + U+010F: "ď" LATIN SMALL LETTER D WITH CARON + U+0111: "đ" LATIN SMALL LETTER D WITH STROKE --> + <string name="more_keys_for_d">ð,ď,đ</string> + <!-- U+0159: "ř" LATIN SMALL LETTER R WITH CARON + U+0155: "ŕ" LATIN SMALL LETTER R WITH ACUTE + U+0157: "ŗ" LATIN SMALL LETTER R WITH CEDILLA --> + <string name="more_keys_for_r">ř,ŕ,ŗ</string> + <!-- U+0165: "ť" LATIN SMALL LETTER T WITH CARON + U+021B: "ț" LATIN SMALL LETTER T WITH COMMA BELOW + U+0163: "ţ" LATIN SMALL LETTER T WITH CEDILLA + U+0167: "ŧ" LATIN SMALL LETTER T WITH STROKE --> + <string name="more_keys_for_t">ť,ț,ţ,ŧ</string> + <!-- U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE + U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE + U+017E: "ž" LATIN SMALL LETTER Z WITH CARON --> + <string name="more_keys_for_z">ź,ż,ž</string> + <!-- U+0137: "ķ" LATIN SMALL LETTER K WITH CEDILLA + U+0138: "ĸ" LATIN SMALL LETTER KRA --> + <string name="more_keys_for_k">ķ,ĸ</string> + <!-- U+013A: "ĺ" LATIN SMALL LETTER L WITH ACUTE + U+013C: "ļ" LATIN SMALL LETTER L WITH CEDILLA + U+013E: "ľ" LATIN SMALL LETTER L WITH CARON + U+0140: "ŀ" LATIN SMALL LETTER L WITH MIDDLE DOT + U+0142: "ł" LATIN SMALL LETTER L WITH STROKE --> + <string name="more_keys_for_l">ĺ,ļ,ľ,ŀ,ł</string> + <!-- U+011F: "ğ" LATIN SMALL LETTER G WITH BREVE + U+0121: "ġ" LATIN SMALL LETTER G WITH DOT ABOVE + U+0123: "ģ" LATIN SMALL LETTER G WITH CEDILLA --> + <string name="more_keys_for_g">ğ,ġ,ģ</string> + <!-- U+0175: "ŵ" LATIN SMALL LETTER W WITH CIRCUMFLEX --> + <string name="more_keys_for_v">w,ŵ</string> + <!-- U+0125: "ĥ" LATIN SMALL LETTER H WITH CIRCUMFLEX + U+0127: "ħ" LATIN SMALL LETTER H WITH STROKE --> + <string name="more_keys_for_h">ĥ,ħ</string> + <!-- U+0175: "ŵ" LATIN SMALL LETTER W WITH CIRCUMFLEX --> + <string name="more_keys_for_w">w,ŵ</string> + <string name="more_keys_for_q">q</string> + <string name="more_keys_for_x">x</string> + <!-- U+015D: "ŝ" LATIN SMALL LETTER S WITH CIRCUMFLEX --> + <string name="keylabel_for_q">ŝ</string> + <!-- U+011D: "ĝ" LATIN SMALL LETTER G WITH CIRCUMFLEX --> + <string name="keylabel_for_w">ĝ</string> + <!-- U+016D: "ŭ" LATIN SMALL LETTER U WITH BREVE --> + <string name="keylabel_for_y">ŭ</string> + <!-- U+0109: "ĉ" LATIN SMALL LETTER C WITH CIRCUMFLEX --> + <string name="keylabel_for_x">ĉ</string> + <!-- U+0135: "ĵ" LATIN SMALL LETTER J WITH CIRCUMFLEX --> + <string name="keylabel_for_spanish_row2_10">ĵ</string> +</resources> diff --git a/tools/maketext/res/values/donottranslate-more-keys.xml b/tools/maketext/res/values/donottranslate-more-keys.xml index 543e93620..4d7100b8c 100644 --- a/tools/maketext/res/values/donottranslate-more-keys.xml +++ b/tools/maketext/res/values/donottranslate-more-keys.xml @@ -177,6 +177,14 @@ <string name="keylabel_for_apostrophe">\'</string> <string name="keyhintlabel_for_apostrophe">\"</string> <string name="more_keys_for_apostrophe">\"</string> + <string name="more_keys_for_q"></string> + <string name="more_keys_for_x"></string> + <string name="keylabel_for_q">q</string> + <string name="keylabel_for_w">w</string> + <string name="keylabel_for_y">y</string> + <string name="keylabel_for_x">x</string> + <!-- U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE --> + <string name="keylabel_for_spanish_row2_10">ñ</string> <string name="more_keys_for_am_pm">!fixedColumnOrder!2,!hasLabels!,\@string/label_time_am,\@string/label_time_pm</string> <string name="settings_as_more_key">!icon/settings_key|!code/key_settings</string> <string name="shortcut_as_more_key">!icon/shortcut_key|!code/key_shortcut</string> diff --git a/tools/maketext/src/com/android/inputmethod/latin/maketext/JarUtils.java b/tools/maketext/src/com/android/inputmethod/latin/maketext/JarUtils.java index 07a6c300e..6d6bc0ea6 100644 --- a/tools/maketext/src/com/android/inputmethod/latin/maketext/JarUtils.java +++ b/tools/maketext/src/com/android/inputmethod/latin/maketext/JarUtils.java @@ -26,7 +26,7 @@ import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; -public class JarUtils { +public final class JarUtils { private JarUtils() { // This utility class is not publicly instantiable. } |