aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-04-06 15:30:42 +0900
committerJean Chalard <jchalard@google.com>2012-04-06 17:07:29 +0900
commitf420df28233c26e555d203185fb292e83b94b8c3 (patch)
treecadd28d7666ed16713b1b46c0cf412f987bcc3bf /java/src
parentb8060399c71a4e23f09eb1f30793043376b42f13 (diff)
downloadlatinime-f420df28233c26e555d203185fb292e83b94b8c3.tar.gz
latinime-f420df28233c26e555d203185fb292e83b94b8c3.tar.xz
latinime-f420df28233c26e555d203185fb292e83b94b8c3.zip
Add support for German umlaut and French ligatures flags
Bug: 6202812 Change-Id: Ib4a7f96f6ef86c840069b15d04393f84d428c176
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java25
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java10
2 files changed, 26 insertions, 9 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
index 820c0a59c..d22332116 100644
--- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
+++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
@@ -17,6 +17,7 @@
package com.android.inputmethod.latin.makedict;
import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
+import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions;
import com.android.inputmethod.latin.makedict.FusionDictionary.Node;
import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString;
@@ -126,8 +127,9 @@ public class BinaryDictInputOutput {
private static final int NOT_A_VERSION_NUMBER = -1;
private static final int FIRST_VERSION_WITH_HEADER_SIZE = 2;
- // No options yet, reserved for future use.
- private static final int OPTIONS = 0;
+ // These options need to be the same numeric values as the one in the native reading code.
+ private static final int GERMAN_UMLAUT_PROCESSING_FLAG = 0x1;
+ private static final int FRENCH_LIGATURE_PROCESSING_FLAG = 0x4;
// TODO: Make this value adaptative to content data, store it in the header, and
// use it in the reading code.
@@ -704,6 +706,14 @@ public class BinaryDictInputOutput {
}
/**
+ * Makes the 2-byte value for options flags.
+ */
+ private static final int makeOptionsValue(final DictionaryOptions options) {
+ return (options.mFrenchLigatureProcessing ? FRENCH_LIGATURE_PROCESSING_FLAG : 0)
+ + (options.mGermanUmlautProcessing ? GERMAN_UMLAUT_PROCESSING_FLAG : 0);
+ }
+
+ /**
* Makes the flag value for a shortcut.
*
* @param more whether there are more attributes after this one.
@@ -918,8 +928,9 @@ public class BinaryDictInputOutput {
buffer[index++] = (byte) (0xFF & version);
}
// Options flags
- buffer[index++] = (byte) (0xFF & (OPTIONS >> 8));
- buffer[index++] = (byte) (0xFF & OPTIONS);
+ final int options = makeOptionsValue(dict.mOptions);
+ buffer[index++] = (byte) (0xFF & (options >> 8));
+ buffer[index++] = (byte) (0xFF & options);
if (version >= FIRST_VERSION_WITH_HEADER_SIZE) {
final int headerSizeOffset = index;
index += 4; // Size of the header size
@@ -1218,7 +1229,7 @@ public class BinaryDictInputOutput {
}
// Read options
- source.readUnsignedShort();
+ final int optionsFlags = source.readUnsignedShort();
final long headerSize;
final HashMap<String, String> options = new HashMap<String, String>();
@@ -1240,7 +1251,9 @@ public class BinaryDictInputOutput {
final Node root = readNode(source, headerSize, reverseNodeMapping, reverseGroupMapping);
FusionDictionary newDict = new FusionDictionary(root,
- new FusionDictionary.DictionaryOptions(options));
+ new FusionDictionary.DictionaryOptions(options,
+ 0 != (optionsFlags & GERMAN_UMLAUT_PROCESSING_FLAG),
+ 0 != (optionsFlags & FRENCH_LIGATURE_PROCESSING_FLAG)));
if (null != dict) {
for (Word w : dict) {
newDict.add(w.mWord, w.mFrequency, w.mShortcutTargets, w.mBigrams);
diff --git a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java
index 3515287b0..40bcfc3aa 100644
--- a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java
+++ b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java
@@ -239,13 +239,17 @@ public class FusionDictionary implements Iterable<Word> {
* There are no options at the moment, so this class is empty.
*/
public static class DictionaryOptions {
- final HashMap<String, String> mAttributes;
- public DictionaryOptions(final HashMap<String, String> attributes) {
+ public final boolean mGermanUmlautProcessing;
+ public final boolean mFrenchLigatureProcessing;
+ public final HashMap<String, String> mAttributes;
+ public DictionaryOptions(final HashMap<String, String> attributes,
+ final boolean germanUmlautProcessing, final boolean frenchLigatureProcessing) {
mAttributes = attributes;
+ mGermanUmlautProcessing = germanUmlautProcessing;
+ mFrenchLigatureProcessing = frenchLigatureProcessing;
}
}
-
public final DictionaryOptions mOptions;
public final Node mRoot;