Add a method to get the flags from a binary dictionary.

This method is not used yet

Change-Id: Ic15d3d423aff2c83c712bc0aa56571d30755e663
main
Jean Chalard 2012-04-06 18:15:11 +09:00
parent 5b0761e6a9
commit e81ac8baa0
3 changed files with 21 additions and 4 deletions

View File

@ -45,6 +45,7 @@ class BinaryFormat {
static int detectFormat(const uint8_t* const dict); static int detectFormat(const uint8_t* const dict);
static unsigned int getHeaderSize(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 int getGroupCountAndForwardPointer(const uint8_t* const dict, int* pos);
static uint8_t getFlagsAndForwardPointer(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); static int32_t getCharCodeAndForwardPointer(const uint8_t* const dict, int* pos);
@ -65,6 +66,15 @@ class BinaryFormat {
const int length); const int length);
static int getWordAtAddress(const uint8_t* const root, const int address, const int maxDepth, static int getWordAtAddress(const uint8_t* const root, const int address, const int maxDepth,
uint16_t* outWord); 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) { inline int BinaryFormat::detectFormat(const uint8_t* const dict) {
@ -89,6 +99,15 @@ inline int BinaryFormat::detectFormat(const uint8_t* const dict) {
} }
} }
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) { inline unsigned int BinaryFormat::getHeaderSize(const uint8_t* const dict) {
switch (detectFormat(dict)) { switch (detectFormat(dict)) {
case 1: case 1:

View File

@ -171,7 +171,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo,
queuePool->clearAll(); queuePool->clearAll();
Correction* masterCorrection = correction; Correction* masterCorrection = correction;
if (REQUIRES_GERMAN_UMLAUT_PROCESSING & flags) if (BinaryFormat::REQUIRES_GERMAN_UMLAUT_PROCESSING & flags)
{ // Incrementally tune the word and try all possibilities { // Incrementally tune the word and try all possibilities
int codesBuffer[getCodesBufferSize(codes, codesSize)]; int codesBuffer[getCodesBufferSize(codes, codesSize)];
int xCoordinatesBuffer[codesSize]; int xCoordinatesBuffer[codesSize];
@ -181,7 +181,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo,
codesSize, flags, codes, codesSize, 0, codesBuffer, masterCorrection, queuePool, codesSize, flags, codes, codesSize, 0, codesBuffer, masterCorrection, queuePool,
GERMAN_UMLAUT_DIGRAPHS, GERMAN_UMLAUT_DIGRAPHS,
sizeof(GERMAN_UMLAUT_DIGRAPHS) / sizeof(GERMAN_UMLAUT_DIGRAPHS[0])); 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 codesBuffer[getCodesBufferSize(codes, codesSize)];
int xCoordinatesBuffer[codesSize]; int xCoordinatesBuffer[codesSize];
int yCoordinatesBuffer[codesSize]; int yCoordinatesBuffer[codesSize];

View File

@ -149,9 +149,7 @@ class UnigramDictionary {
// or something very bad (like, the apocalypse) will happen. // or something very bad (like, the apocalypse) will happen.
// Please update both at the same time. // Please update both at the same time.
enum { 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 GERMAN_UMLAUT_DIGRAPHS[];
static const digraph_t FRENCH_LIGATURES_DIGRAPHS[]; static const digraph_t FRENCH_LIGATURES_DIGRAPHS[];