Remove BinaryDictionary.MAX_PREDICTION and MAX_SPACES, and rename MAX_WORDS to MAX_RESULTS

Change-Id: Iab2a422b367e7521f346481c7fe5e2575f2e9de3
main
Ken Wakasa 2013-01-11 18:59:01 +09:00
parent d8590857bd
commit f6870cc82d
16 changed files with 85 additions and 102 deletions

View File

@ -42,17 +42,13 @@ public final class BinaryDictionary extends Dictionary {
* really long words.
*/
private static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;
private static final int MAX_WORDS = 18;
private static final int MAX_SPACES = 16;
private static final int MAX_PREDICTIONS = 60;
private static final int MAX_RESULTS = Math.max(MAX_PREDICTIONS, MAX_WORDS);
private static final int MAX_RESULTS = 18; /* Must be identical to MAX_RESULTS in defines.h */
private long mNativeDict;
private final Locale mLocale;
private final int[] mInputCodePoints = new int[MAX_WORD_LENGTH];
private final int[] mOutputCodePoints = new int[MAX_WORD_LENGTH * MAX_RESULTS];
private final int[] mSpaceIndices = new int[MAX_SPACES];
private final int[] mSpaceIndices = new int[MAX_RESULTS];
private final int[] mOutputScores = new int[MAX_RESULTS];
private final int[] mOutputTypes = new int[MAX_RESULTS];
@ -80,16 +76,14 @@ public final class BinaryDictionary extends Dictionary {
/**
* Constructor for the binary dictionary. This is supposed to be called from the
* dictionary factory.
* @param context the context to access the environment from.
* @param filename the name of the file to read through native code.
* @param offset the offset of the dictionary data within the file.
* @param length the length of the binary data.
* @param useFullEditDistance whether to use the full edit distance in suggestions
* @param dictType the dictionary type, as a human-readable string
*/
public BinaryDictionary(final Context context, final String filename, final long offset,
final long length, final boolean useFullEditDistance, final Locale locale,
final String dictType) {
public BinaryDictionary(final String filename, final long offset, final long length,
final boolean useFullEditDistance, final Locale locale, final String dictType) {
super(dictType);
mLocale = locale;
mUseFullEditDistance = useFullEditDistance;
@ -101,7 +95,7 @@ public final class BinaryDictionary extends Dictionary {
}
private native long openNative(String sourceDir, long dictOffset, long dictSize,
int maxWordLength, int maxWords, int maxPredictions);
int maxWordLength);
private native void closeNative(long dict);
private native int getFrequencyNative(long dict, int[] word);
private native boolean isValidBigramNative(long dict, int[] word1, int[] word2);
@ -116,8 +110,7 @@ public final class BinaryDictionary extends Dictionary {
// TODO: Move native dict into session
private final void loadDictionary(final String path, final long startOffset,
final long length) {
mNativeDict = openNative(path, startOffset, length, MAX_WORD_LENGTH, MAX_WORDS,
MAX_PREDICTIONS);
mNativeDict = openNative(path, startOffset, length, MAX_WORD_LENGTH);
}
@Override
@ -148,14 +141,12 @@ public final class BinaryDictionary extends Dictionary {
final InputPointers ips = composer.getInputPointers();
final int codesSize = isGesture ? ips.getPointerSize() : composerSize;
// proximityInfo and/or prevWordForBigrams may not be null.
final int tmpCount = getSuggestionsNative(mNativeDict,
proximityInfo.getNativeProximityInfo(), getTraverseSession(sessionId).getSession(),
ips.getXCoordinates(), ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(),
mInputCodePoints, codesSize, 0 /* commitPoint */, isGesture, prevWordCodePointArray,
final int count = getSuggestionsNative(mNativeDict, proximityInfo.getNativeProximityInfo(),
getTraverseSession(sessionId).getSession(), ips.getXCoordinates(),
ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(), mInputCodePoints,
codesSize, 0 /* commitPoint */, isGesture, prevWordCodePointArray,
mUseFullEditDistance, mOutputCodePoints, mOutputScores, mSpaceIndices,
mOutputTypes);
final int count = Math.min(tmpCount, MAX_PREDICTIONS);
final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList();
for (int j = 0; j < count; ++j) {
if (composerSize > 0 && mOutputScores[j] < 1) break;

View File

@ -58,9 +58,8 @@ public final class DictionaryFactory {
BinaryDictionaryGetter.getDictionaryFiles(locale, context);
if (null != assetFileList) {
for (final AssetFileAddress f : assetFileList) {
final BinaryDictionary binaryDictionary =
new BinaryDictionary(context, f.mFilename, f.mOffset, f.mLength,
useFullEditDistance, locale, Dictionary.TYPE_MAIN);
final BinaryDictionary binaryDictionary = new BinaryDictionary(f.mFilename,
f.mOffset, f.mLength, useFullEditDistance, locale, Dictionary.TYPE_MAIN);
if (binaryDictionary.isValidDictionary()) {
dictList.add(binaryDictionary);
}
@ -112,7 +111,7 @@ public final class DictionaryFactory {
Log.e(TAG, "sourceDir is not a file: " + sourceDir);
return null;
}
return new BinaryDictionary(context, sourceDir, afd.getStartOffset(), afd.getLength(),
return new BinaryDictionary(sourceDir, afd.getStartOffset(), afd.getLength(),
false /* useFullEditDistance */, locale, Dictionary.TYPE_MAIN);
} catch (android.content.res.Resources.NotFoundException e) {
Log.e(TAG, "Could not find the resource");
@ -130,17 +129,16 @@ public final class DictionaryFactory {
/**
* Create a dictionary from passed data. This is intended for unit tests only.
* @param context the test context to create this data from.
* @param dictionary the file to read
* @param startOffset the offset in the file where the data starts
* @param length the length of the data
* @param useFullEditDistance whether to use the full edit distance in suggestions
* @return the created dictionary, or null.
*/
public static Dictionary createDictionaryForTest(Context context, File dictionary,
long startOffset, long length, final boolean useFullEditDistance, Locale locale) {
public static Dictionary createDictionaryForTest(File dictionary, long startOffset, long length,
final boolean useFullEditDistance, Locale locale) {
if (dictionary.isFile()) {
return new BinaryDictionary(context, dictionary.getAbsolutePath(), startOffset, length,
return new BinaryDictionary(dictionary.getAbsolutePath(), startOffset, length,
useFullEditDistance, locale, Dictionary.TYPE_MAIN);
} else {
Log.e(TAG, "Could not find the file. path=" + dictionary.getAbsolutePath());

View File

@ -279,9 +279,8 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
final long length = file.length();
// Build the new binary dictionary
final BinaryDictionary newBinaryDictionary =
new BinaryDictionary(mContext, filename, 0, length, true /* useFullEditDistance */,
null, mDictType);
final BinaryDictionary newBinaryDictionary = new BinaryDictionary(filename, 0, length,
true /* useFullEditDistance */, null, mDictType);
if (mBinaryDictionary != null) {
// Ensure all threads accessing the current dictionary have finished before swapping in

View File

@ -72,9 +72,8 @@ public final class Suggest {
}
@UsedForTesting
Suggest(final Context context, final File dictionary,
final long startOffset, final long length, final Locale locale) {
final Dictionary mainDict = DictionaryFactory.createDictionaryForTest(context, dictionary,
Suggest(final File dictionary, final long startOffset, final long length, final Locale locale) {
final Dictionary mainDict = DictionaryFactory.createDictionaryForTest(dictionary,
startOffset, length /* useFullEditDistance */, false, locale);
mLocale = locale;
mMainDictionary = mainDict;

View File

@ -43,7 +43,7 @@ class ProximityInfo;
static void releaseDictBuf(const void *dictBuf, const size_t length, const int fd);
static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object, jstring sourceDir,
jlong dictOffset, jlong dictSize, jint maxWordLength, jint maxWords, jint maxPredictions) {
jlong dictOffset, jlong dictSize, jint maxWordLength) {
PROF_OPEN;
PROF_START(66);
const jsize sourceDirUtf8Length = env->GetStringUTFLength(sourceDir);
@ -117,8 +117,7 @@ static jlong latinime_BinaryDictionary_open(JNIEnv *env, jobject object, jstring
releaseDictBuf(dictBuf, 0, 0);
#endif // USE_MMAP_FOR_DICTIONARY
} else {
dictionary = new Dictionary(dictBuf, static_cast<int>(dictSize), fd, adjust, maxWordLength,
maxWords, maxPredictions);
dictionary = new Dictionary(dictBuf, static_cast<int>(dictSize), fd, adjust, maxWordLength);
}
PROF_END(66);
PROF_CLOSE;
@ -163,6 +162,14 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object,
const jsize outputCodePointsLength = env->GetArrayLength(outputCodePointsArray);
int outputCodePoints[outputCodePointsLength];
const jsize scoresLength = env->GetArrayLength(scoresArray);
/* By the way, let's check the output array length here to make sure */
if (scoresLength < MAX_RESULTS) {
ASSERT(false);
return 0;
}
// Cont'd: Output values
int scores[scoresLength];
const jsize spaceIndicesLength = env->GetArrayLength(spaceIndicesArray);
int spaceIndices[spaceIndicesLength];
@ -270,7 +277,7 @@ static void releaseDictBuf(const void *dictBuf, const size_t length, const int f
}
static JNINativeMethod sMethods[] = {
{"openNative", "(Ljava/lang/String;JJIII)J",
{"openNative", "(Ljava/lang/String;JJI)J",
reinterpret_cast<void *>(latinime_BinaryDictionary_open)},
{"closeNative", "(J)V", reinterpret_cast<void *>(latinime_BinaryDictionary_close)},
{"getSuggestionsNative", "(JJJ[I[I[I[I[IIIZ[IZ[I[I[I[I)I",

View File

@ -26,8 +26,8 @@
namespace latinime {
BigramDictionary::BigramDictionary(const unsigned char *dict, int maxWordLength, int maxPredictions)
: DICT(dict), MAX_WORD_LENGTH(maxWordLength), MAX_PREDICTIONS(maxPredictions) {
BigramDictionary::BigramDictionary(const unsigned char *dict, int maxWordLength)
: DICT(dict), MAX_WORD_LENGTH(maxWordLength) {
if (DEBUG_DICT) {
AKLOGI("BigramDictionary - constructor");
}
@ -36,7 +36,7 @@ BigramDictionary::BigramDictionary(const unsigned char *dict, int maxWordLength,
BigramDictionary::~BigramDictionary() {
}
bool BigramDictionary::addWordBigram(int *word, int length, int frequency, int *bigramFreq,
void BigramDictionary::addWordBigram(int *word, int length, int frequency, int *bigramFreq,
int *bigramCodePoints, int *outputTypes) const {
word[length] = 0;
if (DEBUG_DICT) {
@ -49,7 +49,7 @@ bool BigramDictionary::addWordBigram(int *word, int length, int frequency, int *
// Find the right insertion point
int insertAt = 0;
while (insertAt < MAX_PREDICTIONS) {
while (insertAt < MAX_RESULTS) {
if (frequency > bigramFreq[insertAt] || (bigramFreq[insertAt] == frequency
&& length < Dictionary::wideStrLen(
bigramCodePoints + insertAt * MAX_WORD_LENGTH))) {
@ -58,28 +58,27 @@ bool BigramDictionary::addWordBigram(int *word, int length, int frequency, int *
insertAt++;
}
if (DEBUG_DICT) {
AKLOGI("Bigram: InsertAt -> %d MAX_PREDICTIONS: %d", insertAt, MAX_PREDICTIONS);
AKLOGI("Bigram: InsertAt -> %d MAX_RESULTS: %d", insertAt, MAX_RESULTS);
}
if (insertAt < MAX_PREDICTIONS) {
memmove(bigramFreq + (insertAt + 1),
bigramFreq + insertAt,
(MAX_PREDICTIONS - insertAt - 1) * sizeof(bigramFreq[0]));
bigramFreq[insertAt] = frequency;
outputTypes[insertAt] = Dictionary::KIND_PREDICTION;
memmove(bigramCodePoints + (insertAt + 1) * MAX_WORD_LENGTH,
bigramCodePoints + insertAt * MAX_WORD_LENGTH,
(MAX_PREDICTIONS - insertAt - 1) * sizeof(bigramCodePoints[0]) * MAX_WORD_LENGTH);
int *dest = bigramCodePoints + insertAt * MAX_WORD_LENGTH;
while (length--) {
*dest++ = *word++;
}
*dest = 0; // NULL terminate
if (DEBUG_DICT) {
AKLOGI("Bigram: Added word at %d", insertAt);
}
return true;
if (insertAt >= MAX_RESULTS) {
return;
}
memmove(bigramFreq + (insertAt + 1),
bigramFreq + insertAt,
(MAX_RESULTS - insertAt - 1) * sizeof(bigramFreq[0]));
bigramFreq[insertAt] = frequency;
outputTypes[insertAt] = Dictionary::KIND_PREDICTION;
memmove(bigramCodePoints + (insertAt + 1) * MAX_WORD_LENGTH,
bigramCodePoints + insertAt * MAX_WORD_LENGTH,
(MAX_RESULTS - insertAt - 1) * sizeof(bigramCodePoints[0]) * MAX_WORD_LENGTH);
int *dest = bigramCodePoints + insertAt * MAX_WORD_LENGTH;
while (length--) {
*dest++ = *word++;
}
*dest = 0; // NULL terminate
if (DEBUG_DICT) {
AKLOGI("Bigram: Added word at %d", insertAt);
}
return false;
}
/* Parameters :
@ -135,13 +134,12 @@ int BigramDictionary::getBigrams(const int *prevWord, int prevWordLength, int *i
// here, but it can't get too bad.
const int frequency =
BinaryFormat::computeFrequencyForBigram(unigramFreq, bigramFreqTemp);
if (addWordBigram(bigramBuffer, length, frequency, bigramFreq, bigramCodePoints,
outputTypes)) {
++bigramCount;
}
addWordBigram(bigramBuffer, length, frequency, bigramFreq, bigramCodePoints,
outputTypes);
++bigramCount;
}
} while (BinaryFormat::FLAG_ATTRIBUTE_HAS_NEXT & bigramFlags);
return bigramCount;
return min(bigramCount, MAX_RESULTS);
}
// Returns a pointer to the start of the bigram list.

View File

@ -26,7 +26,7 @@ namespace latinime {
class BigramDictionary {
public:
BigramDictionary(const unsigned char *dict, int maxWordLength, int maxPredictions);
BigramDictionary(const unsigned char *dict, int maxWordLength);
int getBigrams(const int *word, int length, int *inputCodes, int codesSize, int *outWords,
int *frequencies, int *outputTypes) const;
void fillBigramAddressToFrequencyMapAndFilter(const int *prevWord, const int prevWordLength,
@ -35,7 +35,7 @@ class BigramDictionary {
~BigramDictionary();
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(BigramDictionary);
bool addWordBigram(int *word, int length, int frequency, int *bigramFreq, int *bigramCodePoints,
void addWordBigram(int *word, int length, int frequency, int *bigramFreq, int *bigramCodePoints,
int *outputTypes) const;
int getBigramAddress(int *pos, bool advance);
int getBigramFreq(int *pos);
@ -48,7 +48,6 @@ class BigramDictionary {
const unsigned char *DICT;
const int MAX_WORD_LENGTH;
const int MAX_PREDICTIONS;
// TODO: Re-implement proximity correction for bigram correction
static const int MAX_ALTERNATIVES = 1;
};

View File

@ -347,13 +347,8 @@ static inline void prof_out(void) {
#define SUPPRESS_SHORT_MULTIPLE_WORDS_THRESHOLD_FREQ (MAX_FREQ * 58 / 100)
#define MAX_DEPTH_MULTIPLIER 3
#define FIRST_WORD_INDEX 0
#define MAX_SPACES_INTERNAL 16
// TODO: Change this to MAX_WORDS, remove MAX_WORDS in Java, and stop getting it from Java
#define MAX_WORDS_INTERNAL 18
#define MAX_RESULTS 18 /* Must be identical to BinaryDictionary.MAX_RESULTS in Java */
// Max Distance between point to key
#define MAX_POINT_TO_KEY_LENGTH 10000000

View File

@ -28,15 +28,14 @@
namespace latinime {
Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int maxWordLength,
int maxWords, int maxPredictions)
Dictionary::Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int maxWordLength)
: mDict(static_cast<unsigned char *>(dict)),
mOffsetDict((static_cast<unsigned char *>(dict)) + BinaryFormat::getHeaderSize(mDict)),
mDictSize(dictSize), mMmapFd(mmapFd), mDictBufAdjust(dictBufAdjust),
mUnigramDictionary(new UnigramDictionary(mOffsetDict, maxWordLength, maxWords,
mUnigramDictionary(new UnigramDictionary(mOffsetDict, maxWordLength,
BinaryFormat::getFlags(mDict))),
mBigramDictionary(new BigramDictionary(mOffsetDict, maxWordLength, maxPredictions)),
mGestureSuggest(new GestureSuggest(maxWordLength, maxWords)) {
mBigramDictionary(new BigramDictionary(mOffsetDict, maxWordLength)),
mGestureSuggest(new GestureSuggest(maxWordLength)) {
if (DEBUG_DICT) {
if (MAX_WORD_LENGTH_INTERNAL < maxWordLength) {
AKLOGI("Max word length (%d) is greater than %d",

View File

@ -41,8 +41,7 @@ class Dictionary {
const static int KIND_SHORTCUT = 7; // A shortcut
const static int KIND_PREDICTION = 8; // A prediction (== a suggestion with no input)
Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int maxWordLength,
int maxWords, int maxPredictions);
Dictionary(void *dict, int dictSize, int mmapFd, int dictBufAdjust, int maxWordLength);
int getSuggestions(ProximityInfo *proximityInfo, void *traverseSession, int *xcoordinates,
int *ycoordinates, int *times, int *pointerIds, int *codes, int codesSize,

View File

@ -17,7 +17,7 @@
#include "gesture_suggest.h"
namespace latinime {
SuggestInterface *(*GestureSuggest::sGestureSuggestFactoryMethod)(int, int) = 0;
SuggestInterface *(*GestureSuggest::sGestureSuggestFactoryMethod)(int) = 0;
GestureSuggest::~GestureSuggest() {
delete mSuggestInterface;

View File

@ -26,8 +26,8 @@ class ProximityInfo;
class GestureSuggest : public SuggestInterface {
public:
GestureSuggest(const int maxWordLength, const int maxWords)
: mSuggestInterface(getGestureSuggestInstance(maxWordLength, maxWords)) {
GestureSuggest(const int maxWordLength)
: mSuggestInterface(getGestureSuggestInstance(maxWordLength)) {
}
virtual ~GestureSuggest();
@ -43,20 +43,20 @@ class GestureSuggest : public SuggestInterface {
outputTypes);
}
static void setGestureSuggestFactoryMethod(SuggestInterface *(*factoryMethod)(int, int)) {
static void setGestureSuggestFactoryMethod(SuggestInterface *(*factoryMethod)(int)) {
sGestureSuggestFactoryMethod = factoryMethod;
}
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(GestureSuggest);
static SuggestInterface *getGestureSuggestInstance(int maxWordLength, int maxWords) {
static SuggestInterface *getGestureSuggestInstance(int maxWordLength) {
if (!sGestureSuggestFactoryMethod) {
return 0;
}
return sGestureSuggestFactoryMethod(maxWordLength, maxWords);
return sGestureSuggestFactoryMethod(maxWordLength);
}
static SuggestInterface *(*sGestureSuggestFactoryMethod)(int, int);
static SuggestInterface *(*sGestureSuggestFactoryMethod)(int);
SuggestInterface *mSuggestInterface;
};
} // namespace latinime

View File

@ -17,7 +17,7 @@
#include "typing_suggest.h"
namespace latinime {
SuggestInterface *(*TypingSuggest::sTypingSuggestFactoryMethod)(int, int) = 0;
SuggestInterface *(*TypingSuggest::sTypingSuggestFactoryMethod)(int) = 0;
TypingSuggest::~TypingSuggest() {
delete mSuggestInterface;

View File

@ -26,8 +26,8 @@ class ProximityInfo;
class TypingSuggest : public SuggestInterface {
public:
TypingSuggest(const int maxWordLength, const int maxWords)
: mSuggestInterface(getTypingSuggestInstance(maxWordLength, maxWords)) {
TypingSuggest(const int maxWordLength)
: mSuggestInterface(getTypingSuggestInstance(maxWordLength)) {
}
virtual ~TypingSuggest();
@ -43,20 +43,20 @@ class TypingSuggest : public SuggestInterface {
outputTypes);
}
static void setTypingSuggestFactoryMethod(SuggestInterface *(*factoryMethod)(int, int)) {
static void setTypingSuggestFactoryMethod(SuggestInterface *(*factoryMethod)(int)) {
sTypingSuggestFactoryMethod = factoryMethod;
}
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(TypingSuggest);
static SuggestInterface *getTypingSuggestInstance(int maxWordLength, int maxWords) {
static SuggestInterface *getTypingSuggestInstance(int maxWordLength) {
if (!sTypingSuggestFactoryMethod) {
return 0;
}
return sTypingSuggestFactoryMethod(maxWordLength, maxWords);
return sTypingSuggestFactoryMethod(maxWordLength);
}
static SuggestInterface *(*sTypingSuggestFactoryMethod)(int, int);
static SuggestInterface *(*sTypingSuggestFactoryMethod)(int);
SuggestInterface *mSuggestInterface;
};
} // namespace latinime

View File

@ -41,9 +41,9 @@ const UnigramDictionary::digraph_t UnigramDictionary::FRENCH_LIGATURES_DIGRAPHS[
// TODO: check the header
UnigramDictionary::UnigramDictionary(const uint8_t *const streamStart, int maxWordLength,
int maxWords, const unsigned int flags)
: DICT_ROOT(streamStart), MAX_WORD_LENGTH(maxWordLength), MAX_WORDS(maxWords),
ROOT_POS(0), MAX_DIGRAPH_SEARCH_DEPTH(DEFAULT_MAX_DIGRAPH_SEARCH_DEPTH), FLAGS(flags) {
const unsigned int flags)
: DICT_ROOT(streamStart), MAX_WORD_LENGTH(maxWordLength), ROOT_POS(0),
MAX_DIGRAPH_SEARCH_DEPTH(DEFAULT_MAX_DIGRAPH_SEARCH_DEPTH), FLAGS(flags) {
if (DEBUG_DICT) {
AKLOGI("UnigramDictionary - constructor");
}
@ -170,7 +170,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo, const int *x
const int *ycoordinates, const int *codes, const int codesSize,
const std::map<int, int> *bigramMap, const uint8_t *bigramFilter,
const bool useFullEditDistance, int *outWords, int *frequencies, int *outputTypes) const {
WordsPriorityQueuePool queuePool(MAX_WORDS, SUB_QUEUE_MAX_WORDS, MAX_WORD_LENGTH);
WordsPriorityQueuePool queuePool(MAX_RESULTS, SUB_QUEUE_MAX_WORDS, MAX_WORD_LENGTH);
queuePool.clearAll();
Correction masterCorrection;
masterCorrection.resetCorrection();

View File

@ -39,7 +39,7 @@ class UnigramDictionary {
static const int FLAG_MULTIPLE_SUGGEST_ABORT = 0;
static const int FLAG_MULTIPLE_SUGGEST_SKIP = 1;
static const int FLAG_MULTIPLE_SUGGEST_CONTINUE = 2;
UnigramDictionary(const uint8_t *const streamStart, int maxWordLength, int maxWords,
UnigramDictionary(const uint8_t *const streamStart, int maxWordLength,
const unsigned int flags);
int getFrequency(const int *const inWord, const int length) const;
int getBigramPosition(int pos, int *word, int offset, int length) const;
@ -110,7 +110,6 @@ class UnigramDictionary {
const uint8_t *const DICT_ROOT;
const int MAX_WORD_LENGTH;
const int MAX_WORDS;
const int ROOT_POS;
const int MAX_DIGRAPH_SEARCH_DEPTH;
const int FLAGS;