diff options
-rw-r--r-- | java/res/values-fr/donottranslate-config.xml | 23 | ||||
-rw-r--r-- | java/res/values/donottranslate-config.xml | 1 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionary.java | 3 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java | 7 | ||||
-rw-r--r-- | native/src/defines.h | 2 | ||||
-rw-r--r-- | native/src/proximity_info.cpp | 6 | ||||
-rw-r--r-- | native/src/unigram_dictionary.cpp | 13 | ||||
-rw-r--r-- | native/src/unigram_dictionary.h | 4 |
8 files changed, 50 insertions, 9 deletions
diff --git a/java/res/values-fr/donottranslate-config.xml b/java/res/values-fr/donottranslate-config.xml new file mode 100644 index 000000000..1f446d584 --- /dev/null +++ b/java/res/values-fr/donottranslate-config.xml @@ -0,0 +1,23 @@ +<?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> + <bool name="config_require_ligatures_processing">true</bool> +</resources> diff --git a/java/res/values/donottranslate-config.xml b/java/res/values/donottranslate-config.xml index 9b94272e2..ba1cecb6c 100644 --- a/java/res/values/donottranslate-config.xml +++ b/java/res/values/donottranslate-config.xml @@ -20,4 +20,5 @@ <resources> <bool name="config_require_umlaut_processing">false</bool> + <bool name="config_require_ligatures_processing">false</bool> </resources> diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index dfc8c8e9d..7502513f7 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -55,6 +55,8 @@ public class BinaryDictionary extends Dictionary { public static final Flag FLAG_REQUIRES_GERMAN_UMLAUT_PROCESSING = new Flag(R.bool.config_require_umlaut_processing, 0x1); + public static final Flag FLAG_REQUIRES_FRENCH_LIGATURES_PROCESSING = + new Flag(R.bool.config_require_ligatures_processing, 0x4); // FULL_EDIT_DISTANCE is a flag that forces the dictionary to use full words // when computing edit distance, instead of the default behavior of stopping @@ -77,6 +79,7 @@ public class BinaryDictionary extends Dictionary { // actual value will be read from the configuration/extra value at run time for // the configuration at dictionary creation time. FLAG_REQUIRES_GERMAN_UMLAUT_PROCESSING, + FLAG_REQUIRES_FRENCH_LIGATURES_PROCESSING, }; private int mFlags = 0; diff --git a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java index 90c0aac1b..7627700dd 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java @@ -39,7 +39,7 @@ public class SpellCheckerProximityInfo { final protected static void buildProximityIndices(final int[] proximity, final TreeMap<Integer, Integer> indices) { for (int i = 0; i < proximity.length; i += ROW_SIZE) { - if (NUL != proximity[i]) indices.put(proximity[i], i); + if (NUL != proximity[i]) indices.put(proximity[i], i / ROW_SIZE); } } final protected static int computeIndex(final int characterCode, @@ -198,9 +198,8 @@ public class SpellCheckerProximityInfo { // inferior to 1 << 16 public static int getXYForCodePointAndScript(final int codePoint, final int script) { final int index = getIndexOfCodeForScript(codePoint, script); - // TODO: precompute index / ROW_SIZE - final int y = index / (PROXIMITY_GRID_WIDTH * ROW_SIZE); - final int x = (index / ROW_SIZE) % PROXIMITY_GRID_WIDTH; + final int y = index / PROXIMITY_GRID_WIDTH; + final int x = index % PROXIMITY_GRID_WIDTH; if (y > PROXIMITY_GRID_HEIGHT) { // Safety check, should be entirely useless throw new RuntimeException("Wrong y coordinate in spell checker proximity"); diff --git a/native/src/defines.h b/native/src/defines.h index 21215343e..e882c3714 100644 --- a/native/src/defines.h +++ b/native/src/defines.h @@ -171,7 +171,7 @@ static inline void prof_out(void) { #define EQUIVALENT_CHAR_WITHOUT_DISTANCE_INFO -2 #define PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO -3 #define ADDITIONAL_PROXIMITY_CHAR_DISTANCE_INFO -4 -#define NOT_A_INDEX -1 +#define NOT_AN_INDEX -1 #define NOT_A_FREQUENCY -1 #define KEYCODE_SPACE ' ' diff --git a/native/src/proximity_info.cpp b/native/src/proximity_info.cpp index 47f137610..2bfb15d8c 100644 --- a/native/src/proximity_info.cpp +++ b/native/src/proximity_info.cpp @@ -304,7 +304,7 @@ inline float square(const float x) { return x * x; } float ProximityInfo::calculateNormalizedSquaredDistance( const int keyIndex, const int inputIndex) const { - if (keyIndex == NOT_A_INDEX) { + if (keyIndex == NOT_AN_INDEX) { return NOT_A_DISTANCE_FLOAT; } if (!hasSweetSpotData(keyIndex)) { @@ -325,11 +325,11 @@ bool ProximityInfo::hasInputCoordinates() const { int ProximityInfo::getKeyIndex(const int c) const { if (KEY_COUNT == 0) { // We do not have the coordinate data - return NOT_A_INDEX; + return NOT_AN_INDEX; } const unsigned short baseLowerC = toBaseLowerCase(c); if (baseLowerC > MAX_CHAR_CODE) { - return NOT_A_INDEX; + return NOT_AN_INDEX; } return mCodeToKeyIndex[baseLowerC]; } diff --git a/native/src/unigram_dictionary.cpp b/native/src/unigram_dictionary.cpp index 563541dce..304a4df38 100644 --- a/native/src/unigram_dictionary.cpp +++ b/native/src/unigram_dictionary.cpp @@ -34,6 +34,10 @@ const UnigramDictionary::digraph_t UnigramDictionary::GERMAN_UMLAUT_DIGRAPHS[] = { 'o', 'e', 0x00F6 }, // U+00F6 : LATIN SMALL LETTER O WITH DIAERESIS { 'u', 'e', 0x00FC } }; // U+00FC : LATIN SMALL LETTER U WITH DIAERESIS +const UnigramDictionary::digraph_t UnigramDictionary::FRENCH_LIGATURES_DIGRAPHS[] = + { { 'a', 'e', 0x00E6 }, // U+00E6 : LATIN SMALL LETTER AE + { 'o', 'e', 0x0153 } }; // U+0153 : LATIN SMALL LIGATURE OE + // TODO: check the header UnigramDictionary::UnigramDictionary(const uint8_t* const streamStart, int typedLetterMultiplier, int fullWordMultiplier, int maxWordLength, int maxWords, int maxProximityChars, @@ -181,6 +185,15 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo, codesSize, flags, codes, codesSize, 0, codesBuffer, masterCorrection, queuePool, GERMAN_UMLAUT_DIGRAPHS, sizeof(GERMAN_UMLAUT_DIGRAPHS) / sizeof(GERMAN_UMLAUT_DIGRAPHS[0])); + } else if (REQUIRES_FRENCH_LIGATURES_PROCESSING & flags) { + int codesBuffer[getCodesBufferSize(codes, codesSize, MAX_PROXIMITY_CHARS)]; + int xCoordinatesBuffer[codesSize]; + int yCoordinatesBuffer[codesSize]; + getWordWithDigraphSuggestionsRec(proximityInfo, xcoordinates, ycoordinates, codesBuffer, + xCoordinatesBuffer, yCoordinatesBuffer, + codesSize, flags, codes, codesSize, 0, codesBuffer, masterCorrection, queuePool, + FRENCH_LIGATURES_DIGRAPHS, + sizeof(FRENCH_LIGATURES_DIGRAPHS) / sizeof(FRENCH_LIGATURES_DIGRAPHS[0])); } else { // Normal processing getWordSuggestions(proximityInfo, xcoordinates, ycoordinates, codes, codesSize, flags, masterCorrection, queuePool); diff --git a/native/src/unigram_dictionary.h b/native/src/unigram_dictionary.h index b85913ffb..f9ee5089d 100644 --- a/native/src/unigram_dictionary.h +++ b/native/src/unigram_dictionary.h @@ -157,9 +157,11 @@ class UnigramDictionary { // Please update both at the same time. enum { REQUIRES_GERMAN_UMLAUT_PROCESSING = 0x1, - USE_FULL_EDIT_DISTANCE = 0x2 + USE_FULL_EDIT_DISTANCE = 0x2, + REQUIRES_FRENCH_LIGATURES_PROCESSING = 0x4 }; static const digraph_t GERMAN_UMLAUT_DIGRAPHS[]; + static const digraph_t FRENCH_LIGATURES_DIGRAPHS[]; // Still bundled members unsigned short mWord[MAX_WORD_LENGTH_INTERNAL];// TODO: remove |