Add a method to get the flags from a binary dictionary.
This method is not used yet
Change-Id: Ic15d3d423aff2c83c712bc0aa56571d30755e663
diff --git a/native/jni/src/binary_format.h b/native/jni/src/binary_format.h
index 16d57a6..f593024 100644
--- a/native/jni/src/binary_format.h
+++ b/native/jni/src/binary_format.h
@@ -45,6 +45,7 @@
static int detectFormat(const uint8_t* const dict);
static unsigned int getHeaderSize(const uint8_t* const dict);
+ static unsigned int getFlags(const uint8_t* const dict);
static int getGroupCountAndForwardPointer(const uint8_t* const dict, int* pos);
static uint8_t getFlagsAndForwardPointer(const uint8_t* const dict, int* pos);
static int32_t getCharCodeAndForwardPointer(const uint8_t* const dict, int* pos);
@@ -65,6 +66,15 @@
const int length);
static int getWordAtAddress(const uint8_t* const root, const int address, const int maxDepth,
uint16_t* outWord);
+
+ // Flags for special processing
+ // Those *must* match the flags in makedict (BinaryDictInputOutput#*_PROCESSING_FLAG) or
+ // something very bad (like, the apocalypse) will happen. Please update both at the same time.
+ enum {
+ REQUIRES_GERMAN_UMLAUT_PROCESSING = 0x1,
+ REQUIRES_FRENCH_LIGATURES_PROCESSING = 0x4
+ };
+ const static unsigned int NO_FLAGS = 0;
};
inline int BinaryFormat::detectFormat(const uint8_t* const dict) {
@@ -89,6 +99,15 @@
}
}
+inline unsigned int BinaryFormat::getFlags(const uint8_t* const dict) {
+ switch (detectFormat(dict)) {
+ case 1:
+ return NO_FLAGS;
+ default:
+ return (dict[6] << 8) + dict[7];
+ }
+}
+
inline unsigned int BinaryFormat::getHeaderSize(const uint8_t* const dict) {
switch (detectFormat(dict)) {
case 1:
diff --git a/native/jni/src/unigram_dictionary.cpp b/native/jni/src/unigram_dictionary.cpp
index ea10e58..06a2a6b 100644
--- a/native/jni/src/unigram_dictionary.cpp
+++ b/native/jni/src/unigram_dictionary.cpp
@@ -171,7 +171,7 @@
queuePool->clearAll();
Correction* masterCorrection = correction;
- if (REQUIRES_GERMAN_UMLAUT_PROCESSING & flags)
+ if (BinaryFormat::REQUIRES_GERMAN_UMLAUT_PROCESSING & flags)
{ // Incrementally tune the word and try all possibilities
int codesBuffer[getCodesBufferSize(codes, codesSize)];
int xCoordinatesBuffer[codesSize];
@@ -181,7 +181,7 @@
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) {
+ } else if (BinaryFormat::REQUIRES_FRENCH_LIGATURES_PROCESSING & flags) {
int codesBuffer[getCodesBufferSize(codes, codesSize)];
int xCoordinatesBuffer[codesSize];
int yCoordinatesBuffer[codesSize];
diff --git a/native/jni/src/unigram_dictionary.h b/native/jni/src/unigram_dictionary.h
index c61b026..e2ff6ad 100644
--- a/native/jni/src/unigram_dictionary.h
+++ b/native/jni/src/unigram_dictionary.h
@@ -149,9 +149,7 @@
// or something very bad (like, the apocalypse) will happen.
// Please update both at the same time.
enum {
- REQUIRES_GERMAN_UMLAUT_PROCESSING = 0x1,
USE_FULL_EDIT_DISTANCE = 0x2,
- REQUIRES_FRENCH_LIGATURES_PROCESSING = 0x4
};
static const digraph_t GERMAN_UMLAUT_DIGRAPHS[];
static const digraph_t FRENCH_LIGATURES_DIGRAPHS[];