2010-12-02 05:53:24 +00:00
|
|
|
/*
|
2012-07-25 08:51:43 +00:00
|
|
|
*
|
|
|
|
* Copyright 2010, 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.
|
|
|
|
*/
|
2010-12-02 05:53:24 +00:00
|
|
|
|
|
|
|
#ifndef LATINIME_DEFINES_H
|
|
|
|
#define LATINIME_DEFINES_H
|
|
|
|
|
2011-07-14 00:01:09 +00:00
|
|
|
#if defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
|
2012-07-27 09:06:06 +00:00
|
|
|
#include <android/log.h>
|
|
|
|
#ifndef LOG_TAG
|
|
|
|
#define LOG_TAG "LatinIME: "
|
|
|
|
#endif
|
|
|
|
#define AKLOGE(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, fmt, ##__VA_ARGS__)
|
|
|
|
#define AKLOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, fmt, ##__VA_ARGS__)
|
2012-01-16 07:21:21 +00:00
|
|
|
|
|
|
|
#define DUMP_WORD(word, length) do { dumpWord(word, length); } while(0)
|
2012-05-30 08:28:34 +00:00
|
|
|
#define DUMP_WORD_INT(word, length) do { dumpWordInt(word, length); } while(0)
|
2012-01-16 07:21:21 +00:00
|
|
|
|
2012-07-25 08:51:43 +00:00
|
|
|
static inline void dumpWord(const unsigned short *word, const int length) {
|
2012-03-06 06:35:46 +00:00
|
|
|
static char charBuf[50];
|
2012-01-16 07:21:21 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < length; ++i) {
|
|
|
|
charBuf[i] = word[i];
|
|
|
|
}
|
|
|
|
charBuf[length] = 0;
|
|
|
|
AKLOGI("[ %s ]", charBuf);
|
|
|
|
}
|
|
|
|
|
2012-07-25 08:51:43 +00:00
|
|
|
static inline void dumpWordInt(const int *word, const int length) {
|
2012-05-30 08:28:34 +00:00
|
|
|
static char charBuf[50];
|
|
|
|
|
|
|
|
for (int i = 0; i < length; ++i) {
|
|
|
|
charBuf[i] = word[i];
|
|
|
|
}
|
|
|
|
charBuf[length] = 0;
|
|
|
|
AKLOGI("i[ %s ]", charBuf);
|
|
|
|
}
|
|
|
|
|
2011-07-14 00:01:09 +00:00
|
|
|
#else
|
2012-01-13 09:01:22 +00:00
|
|
|
#define AKLOGE(fmt, ...)
|
|
|
|
#define AKLOGI(fmt, ...)
|
2012-01-16 07:21:21 +00:00
|
|
|
#define DUMP_WORD(word, length)
|
2012-05-30 08:28:34 +00:00
|
|
|
#define DUMP_WORD_INT(word, length)
|
2011-07-14 00:01:09 +00:00
|
|
|
#endif
|
|
|
|
|
2011-07-13 05:40:30 +00:00
|
|
|
#ifdef FLAG_DO_PROFILE
|
2011-01-05 05:13:07 +00:00
|
|
|
// Profiler
|
|
|
|
#include <time.h>
|
2012-01-13 09:01:22 +00:00
|
|
|
|
2011-01-05 05:13:07 +00:00
|
|
|
#define PROF_BUF_SIZE 100
|
2012-05-16 11:42:12 +00:00
|
|
|
static float profile_buf[PROF_BUF_SIZE];
|
|
|
|
static float profile_old[PROF_BUF_SIZE];
|
2011-01-05 05:13:07 +00:00
|
|
|
static unsigned int profile_counter[PROF_BUF_SIZE];
|
|
|
|
|
2011-01-07 06:01:51 +00:00
|
|
|
#define PROF_RESET prof_reset()
|
|
|
|
#define PROF_COUNT(prof_buf_id) ++profile_counter[prof_buf_id]
|
|
|
|
#define PROF_OPEN do { PROF_RESET; PROF_START(PROF_BUF_SIZE - 1); } while(0)
|
|
|
|
#define PROF_START(prof_buf_id) do { \
|
|
|
|
PROF_COUNT(prof_buf_id); profile_old[prof_buf_id] = (clock()); } while(0)
|
|
|
|
#define PROF_CLOSE do { PROF_END(PROF_BUF_SIZE - 1); PROF_OUTALL; } while(0)
|
|
|
|
#define PROF_END(prof_buf_id) profile_buf[prof_buf_id] += ((clock()) - profile_old[prof_buf_id])
|
|
|
|
#define PROF_CLOCKOUT(prof_buf_id) \
|
2012-01-13 09:01:22 +00:00
|
|
|
AKLOGI("%s : clock is %f", __FUNCTION__, (clock() - profile_old[prof_buf_id]))
|
|
|
|
#define PROF_OUTALL do { AKLOGI("--- %s ---", __FUNCTION__); prof_out(); } while(0)
|
2011-01-07 06:01:51 +00:00
|
|
|
|
2012-03-06 06:35:46 +00:00
|
|
|
static inline void prof_reset(void) {
|
2011-01-07 06:01:51 +00:00
|
|
|
for (int i = 0; i < PROF_BUF_SIZE; ++i) {
|
2011-01-05 05:13:07 +00:00
|
|
|
profile_buf[i] = 0;
|
|
|
|
profile_old[i] = 0;
|
|
|
|
profile_counter[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-06 06:35:46 +00:00
|
|
|
static inline void prof_out(void) {
|
2011-01-05 05:13:07 +00:00
|
|
|
if (profile_counter[PROF_BUF_SIZE - 1] != 1) {
|
2012-01-13 09:01:22 +00:00
|
|
|
AKLOGI("Error: You must call PROF_OPEN before PROF_CLOSE.");
|
2011-01-05 05:13:07 +00:00
|
|
|
}
|
2012-01-13 09:01:22 +00:00
|
|
|
AKLOGI("Total time is %6.3f ms.",
|
2012-05-16 11:42:12 +00:00
|
|
|
profile_buf[PROF_BUF_SIZE - 1] * 1000 / (float)CLOCKS_PER_SEC);
|
|
|
|
float all = 0;
|
2011-01-07 06:01:51 +00:00
|
|
|
for (int i = 0; i < PROF_BUF_SIZE - 1; ++i) {
|
2011-01-05 05:13:07 +00:00
|
|
|
all += profile_buf[i];
|
|
|
|
}
|
2011-01-07 06:01:51 +00:00
|
|
|
if (all == 0) all = 1;
|
|
|
|
for (int i = 0; i < PROF_BUF_SIZE - 1; ++i) {
|
|
|
|
if (profile_buf[i] != 0) {
|
2012-01-13 09:01:22 +00:00
|
|
|
AKLOGI("(%d): Used %4.2f%%, %8.4f ms. Called %d times.",
|
2011-01-07 06:01:51 +00:00
|
|
|
i, (profile_buf[i] * 100 / all),
|
2012-05-16 11:42:12 +00:00
|
|
|
profile_buf[i] * 1000 / (float)CLOCKS_PER_SEC, profile_counter[i]);
|
2011-01-07 06:01:51 +00:00
|
|
|
}
|
2011-01-05 05:13:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-13 05:40:30 +00:00
|
|
|
#else // FLAG_DO_PROFILE
|
2011-01-05 05:13:07 +00:00
|
|
|
#define PROF_BUF_SIZE 0
|
|
|
|
#define PROF_RESET
|
|
|
|
#define PROF_COUNT(prof_buf_id)
|
|
|
|
#define PROF_OPEN
|
|
|
|
#define PROF_START(prof_buf_id)
|
|
|
|
#define PROF_CLOSE
|
|
|
|
#define PROF_END(prof_buf_id)
|
|
|
|
#define PROF_CLOCK_OUT(prof_buf_id)
|
|
|
|
#define PROF_CLOCKOUT(prof_buf_id)
|
|
|
|
#define PROF_OUTALL
|
|
|
|
|
2011-07-13 05:40:30 +00:00
|
|
|
#endif // FLAG_DO_PROFILE
|
|
|
|
|
|
|
|
#ifdef FLAG_DBG
|
|
|
|
#define DEBUG_DICT true
|
|
|
|
#define DEBUG_DICT_FULL false
|
2011-08-11 16:05:27 +00:00
|
|
|
#define DEBUG_EDIT_DISTANCE false
|
2011-08-19 13:05:59 +00:00
|
|
|
#define DEBUG_SHOW_FOUND_WORD false
|
2011-07-13 05:40:30 +00:00
|
|
|
#define DEBUG_NODE DEBUG_DICT_FULL
|
|
|
|
#define DEBUG_TRACE DEBUG_DICT_FULL
|
2011-12-16 14:15:06 +00:00
|
|
|
#define DEBUG_PROXIMITY_INFO false
|
2012-03-13 13:07:56 +00:00
|
|
|
#define DEBUG_PROXIMITY_CHARS false
|
2011-08-19 13:05:59 +00:00
|
|
|
#define DEBUG_CORRECTION false
|
2012-01-17 06:59:15 +00:00
|
|
|
#define DEBUG_CORRECTION_FREQ false
|
|
|
|
#define DEBUG_WORDS_PRIORITY_QUEUE false
|
2011-07-13 05:40:30 +00:00
|
|
|
|
|
|
|
#else // FLAG_DBG
|
2011-07-14 00:01:09 +00:00
|
|
|
|
2011-07-13 05:40:30 +00:00
|
|
|
#define DEBUG_DICT false
|
|
|
|
#define DEBUG_DICT_FULL false
|
2011-08-11 16:05:27 +00:00
|
|
|
#define DEBUG_EDIT_DISTANCE false
|
2011-07-13 05:40:30 +00:00
|
|
|
#define DEBUG_SHOW_FOUND_WORD false
|
|
|
|
#define DEBUG_NODE false
|
|
|
|
#define DEBUG_TRACE false
|
|
|
|
#define DEBUG_PROXIMITY_INFO false
|
2012-03-13 13:07:56 +00:00
|
|
|
#define DEBUG_PROXIMITY_CHARS false
|
2011-08-19 13:05:59 +00:00
|
|
|
#define DEBUG_CORRECTION false
|
|
|
|
#define DEBUG_CORRECTION_FREQ false
|
2011-12-12 11:53:22 +00:00
|
|
|
#define DEBUG_WORDS_PRIORITY_QUEUE false
|
2011-07-13 05:40:30 +00:00
|
|
|
|
2010-12-02 05:53:24 +00:00
|
|
|
#endif // FLAG_DBG
|
|
|
|
|
2010-12-08 08:05:39 +00:00
|
|
|
#ifndef U_SHORT_MAX
|
2011-09-20 05:03:42 +00:00
|
|
|
#define U_SHORT_MAX 65535 // ((1 << 16) - 1)
|
2010-12-08 08:05:39 +00:00
|
|
|
#endif
|
2011-02-18 08:50:58 +00:00
|
|
|
#ifndef S_INT_MAX
|
2011-03-05 06:50:19 +00:00
|
|
|
#define S_INT_MAX 2147483647 // ((1 << 31) - 1)
|
2011-02-18 08:50:58 +00:00
|
|
|
#endif
|
2010-12-08 08:05:39 +00:00
|
|
|
|
2011-01-07 06:01:51 +00:00
|
|
|
// Define this to use mmap() for dictionary loading. Undefine to use malloc() instead of mmap().
|
|
|
|
// We measured and compared performance of both, and found mmap() is fairly good in terms of
|
|
|
|
// loading time, and acceptable even for several initial lookups which involve page faults.
|
|
|
|
#define USE_MMAP_FOR_DICTIONARY
|
|
|
|
|
2010-12-02 05:53:24 +00:00
|
|
|
// 22-bit address = ~4MB dictionary size limit, which on average would be about 200k-300k words
|
|
|
|
#define ADDRESS_MASK 0x3FFFFF
|
|
|
|
|
|
|
|
// The bit that decides if an address follows in the next 22 bits
|
|
|
|
#define FLAG_ADDRESS_MASK 0x40
|
|
|
|
// The bit that decides if this is a terminal node for a word. The node could still have children,
|
|
|
|
// if the word has other endings.
|
|
|
|
#define FLAG_TERMINAL_MASK 0x80
|
|
|
|
|
|
|
|
#define FLAG_BIGRAM_READ 0x80
|
|
|
|
#define FLAG_BIGRAM_CHILDEXIST 0x40
|
|
|
|
#define FLAG_BIGRAM_CONTINUED 0x80
|
|
|
|
#define FLAG_BIGRAM_FREQ 0x7F
|
|
|
|
|
|
|
|
#define DICTIONARY_VERSION_MIN 200
|
|
|
|
#define NOT_VALID_WORD -99
|
2011-06-28 11:45:05 +00:00
|
|
|
#define NOT_A_CHARACTER -1
|
2011-10-05 05:55:07 +00:00
|
|
|
#define NOT_A_DISTANCE -1
|
2012-01-25 09:11:26 +00:00
|
|
|
#define NOT_A_COORDINATE -1
|
2011-10-06 10:12:20 +00:00
|
|
|
#define EQUIVALENT_CHAR_WITHOUT_DISTANCE_INFO -2
|
|
|
|
#define PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO -3
|
2012-01-31 08:15:43 +00:00
|
|
|
#define ADDITIONAL_PROXIMITY_CHAR_DISTANCE_INFO -4
|
2012-03-23 08:05:03 +00:00
|
|
|
#define NOT_AN_INDEX -1
|
2012-04-23 09:51:00 +00:00
|
|
|
#define NOT_A_PROBABILITY -1
|
2010-12-02 05:53:24 +00:00
|
|
|
|
2011-03-04 14:06:45 +00:00
|
|
|
#define KEYCODE_SPACE ' '
|
|
|
|
|
2011-10-05 09:11:42 +00:00
|
|
|
#define CALIBRATE_SCORE_BY_TOUCH_COORDINATES true
|
2011-09-28 03:59:43 +00:00
|
|
|
|
2010-12-08 08:05:39 +00:00
|
|
|
#define SUGGEST_WORDS_WITH_MISSING_CHARACTER true
|
|
|
|
#define SUGGEST_WORDS_WITH_EXCESSIVE_CHARACTER true
|
2010-12-09 13:08:33 +00:00
|
|
|
#define SUGGEST_WORDS_WITH_TRANSPOSED_CHARACTERS true
|
2012-01-26 13:49:13 +00:00
|
|
|
#define SUGGEST_MULTIPLE_WORDS true
|
2010-12-09 13:08:33 +00:00
|
|
|
|
2011-01-27 05:20:22 +00:00
|
|
|
// The following "rate"s are used as a multiplier before dividing by 100, so they are in percent.
|
2011-04-13 08:23:27 +00:00
|
|
|
#define WORDS_WITH_MISSING_CHARACTER_DEMOTION_RATE 80
|
2011-04-11 07:14:45 +00:00
|
|
|
#define WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X 12
|
2012-01-17 06:58:23 +00:00
|
|
|
#define WORDS_WITH_MISSING_SPACE_CHARACTER_DEMOTION_RATE 58
|
2012-01-23 07:52:37 +00:00
|
|
|
#define WORDS_WITH_MISTYPED_SPACE_DEMOTION_RATE 50
|
2010-12-09 13:08:33 +00:00
|
|
|
#define WORDS_WITH_EXCESSIVE_CHARACTER_DEMOTION_RATE 75
|
2010-12-13 05:42:35 +00:00
|
|
|
#define WORDS_WITH_EXCESSIVE_CHARACTER_OUT_OF_PROXIMITY_DEMOTION_RATE 75
|
2012-01-16 09:38:32 +00:00
|
|
|
#define WORDS_WITH_TRANSPOSED_CHARACTERS_DEMOTION_RATE 70
|
2011-01-26 18:23:39 +00:00
|
|
|
#define FULL_MATCHED_WORDS_PROMOTION_RATE 120
|
2011-04-14 10:13:34 +00:00
|
|
|
#define WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE 90
|
2012-02-02 09:49:22 +00:00
|
|
|
#define WORDS_WITH_ADDITIONAL_PROXIMITY_CHARACTER_DEMOTION_RATE 70
|
2011-08-10 13:19:33 +00:00
|
|
|
#define WORDS_WITH_MATCH_SKIP_PROMOTION_RATE 105
|
2012-02-02 09:49:22 +00:00
|
|
|
#define WORDS_WITH_JUST_ONE_CORRECTION_PROMOTION_RATE 148
|
|
|
|
#define WORDS_WITH_JUST_ONE_CORRECTION_PROMOTION_MULTIPLIER 3
|
2011-08-19 13:05:59 +00:00
|
|
|
#define CORRECTION_COUNT_RATE_DEMOTION_RATE_BASE 45
|
|
|
|
#define INPUT_EXCEEDS_OUTPUT_DEMOTION_RATE 70
|
|
|
|
#define FIRST_CHAR_DIFFERENT_DEMOTION_RATE 96
|
2011-10-03 10:21:13 +00:00
|
|
|
#define TWO_WORDS_CAPITALIZED_DEMOTION_RATE 50
|
2012-01-17 06:58:23 +00:00
|
|
|
#define TWO_WORDS_CORRECTION_DEMOTION_BASE 80
|
|
|
|
#define TWO_WORDS_PLUS_OTHER_ERROR_CORRECTION_DEMOTION_DIVIDER 1
|
2011-10-06 10:12:20 +00:00
|
|
|
#define ZERO_DISTANCE_PROMOTION_RATE 110
|
|
|
|
#define NEUTRAL_SCORE_SQUARED_RADIUS 8.0f
|
|
|
|
#define HALF_SCORE_SQUARED_RADIUS 32.0f
|
2012-01-30 09:18:30 +00:00
|
|
|
#define MAX_FREQ 255
|
2012-05-15 10:24:47 +00:00
|
|
|
#define MAX_BIGRAM_FREQ 15
|
2010-12-02 05:53:24 +00:00
|
|
|
|
2011-12-14 06:04:58 +00:00
|
|
|
// This must be greater than or equal to MAX_WORD_LENGTH defined in BinaryDictionary.java
|
2010-12-06 12:28:24 +00:00
|
|
|
// This is only used for the size of array. Not to be used in c functions.
|
|
|
|
#define MAX_WORD_LENGTH_INTERNAL 48
|
2010-12-02 11:19:59 +00:00
|
|
|
|
2012-06-05 08:55:52 +00:00
|
|
|
// This must be the same as ProximityInfo#MAX_PROXIMITY_CHARS_SIZE, currently it's 16.
|
|
|
|
#define MAX_PROXIMITY_CHARS_SIZE_INTERNAL 16
|
|
|
|
|
2012-01-31 08:15:43 +00:00
|
|
|
// This must be equal to ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE in KeyDetector.java
|
|
|
|
#define ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE 2
|
|
|
|
|
2011-12-15 07:49:12 +00:00
|
|
|
// Word limit for sub queues used in WordsPriorityQueuePool. Sub queues are temporary queues used
|
|
|
|
// for better performance.
|
2012-01-16 07:21:21 +00:00
|
|
|
// Holds up to 1 candidate for each word
|
|
|
|
#define SUB_QUEUE_MAX_WORDS 1
|
2012-01-13 06:41:17 +00:00
|
|
|
#define SUB_QUEUE_MAX_COUNT 10
|
2012-01-17 06:58:23 +00:00
|
|
|
#define SUB_QUEUE_MIN_WORD_LENGTH 4
|
2012-05-31 06:04:58 +00:00
|
|
|
// TODO: Extend this limitation
|
|
|
|
#define MULTIPLE_WORDS_SUGGESTION_MAX_WORDS 5
|
2012-05-30 08:28:34 +00:00
|
|
|
// TODO: Remove this limitation
|
|
|
|
#define MULTIPLE_WORDS_SUGGESTION_MAX_WORD_LENGTH 12
|
|
|
|
// TODO: Remove this limitation
|
2012-05-31 06:04:58 +00:00
|
|
|
#define MULTIPLE_WORDS_SUGGESTION_MAX_TOTAL_TRAVERSE_COUNT 45
|
2012-01-30 09:18:30 +00:00
|
|
|
#define MULTIPLE_WORDS_DEMOTION_RATE 80
|
|
|
|
#define MIN_INPUT_LENGTH_FOR_THREE_OR_MORE_WORDS_CORRECTION 6
|
2011-12-15 07:49:12 +00:00
|
|
|
|
2012-05-15 10:24:47 +00:00
|
|
|
#define TWO_WORDS_CORRECTION_WITH_OTHER_ERROR_THRESHOLD 0.35
|
|
|
|
#define START_TWO_WORDS_CORRECTION_THRESHOLD 0.185
|
2012-05-23 10:55:27 +00:00
|
|
|
/* heuristic... This should be changed if we change the unit of the frequency. */
|
|
|
|
#define SUPPRESS_SHORT_MULTIPLE_WORDS_THRESHOLD_FREQ (MAX_FREQ * 58 / 100)
|
2012-01-17 06:59:15 +00:00
|
|
|
|
2010-12-03 10:38:08 +00:00
|
|
|
#define MAX_DEPTH_MULTIPLIER 3
|
|
|
|
|
2012-01-30 04:53:58 +00:00
|
|
|
#define FIRST_WORD_INDEX 0
|
2012-01-23 07:52:37 +00:00
|
|
|
|
2012-06-28 06:13:57 +00:00
|
|
|
#define MAX_SPACES_INTERNAL 16
|
|
|
|
|
2012-03-06 10:54:03 +00:00
|
|
|
// TODO: Reduce this constant if possible; check the maximum number of digraphs in the same
|
|
|
|
// word in the dictionary for languages with digraphs, like German and French
|
|
|
|
#define DEFAULT_MAX_DIGRAPH_SEARCH_DEPTH 5
|
2011-03-04 03:17:48 +00:00
|
|
|
|
2010-12-13 05:42:35 +00:00
|
|
|
// Minimum suggest depth for one word for all cases except for missing space suggestions.
|
|
|
|
#define MIN_SUGGEST_DEPTH 1
|
2012-01-26 13:49:13 +00:00
|
|
|
#define MIN_USER_TYPED_LENGTH_FOR_MULTIPLE_WORD_SUGGESTION 3
|
2010-12-13 05:42:35 +00:00
|
|
|
#define MIN_USER_TYPED_LENGTH_FOR_EXCESSIVE_CHARACTER_SUGGESTION 3
|
2010-12-08 08:05:39 +00:00
|
|
|
|
2012-05-02 10:05:27 +00:00
|
|
|
// Size, in bytes, of the bloom filter index for bigrams
|
|
|
|
// 128 gives us 1024 buckets. The probability of false positive is (1 - e ** (-kn/m))**k,
|
|
|
|
// where k is the number of hash functions, n the number of bigrams, and m the number of
|
|
|
|
// bits we can test.
|
|
|
|
// At the moment 100 is the maximum number of bigrams for a word with the current
|
|
|
|
// dictionaries, so n = 100. 1024 buckets give us m = 1024.
|
|
|
|
// With 1 hash function, our false positive rate is about 9.3%, which should be enough for
|
|
|
|
// our uses since we are only using this to increase average performance. For the record,
|
|
|
|
// k = 2 gives 3.1% and k = 3 gives 1.6%. With k = 1, making m = 2048 gives 4.8%,
|
|
|
|
// and m = 4096 gives 2.4%.
|
|
|
|
#define BIGRAM_FILTER_BYTE_SIZE 128
|
|
|
|
// Must be smaller than BIGRAM_FILTER_BYTE_SIZE * 8, and preferably prime. 1021 is the largest
|
|
|
|
// prime under 128 * 8.
|
|
|
|
#define BIGRAM_FILTER_MODULO 1021
|
|
|
|
#if BIGRAM_FILTER_BYTE_SIZE * 8 < BIGRAM_FILTER_MODULO
|
|
|
|
#error "BIGRAM_FILTER_MODULO is larger than BIGRAM_FILTER_BYTE_SIZE"
|
|
|
|
#endif
|
|
|
|
|
2012-02-03 12:24:53 +00:00
|
|
|
template<typename T> inline T min(T a, T b) { return a < b ? a : b; }
|
|
|
|
template<typename T> inline T max(T a, T b) { return a > b ? a : b; }
|
2010-12-06 12:28:24 +00:00
|
|
|
|
2011-09-28 03:59:43 +00:00
|
|
|
// The ratio of neutral area radius to sweet spot radius.
|
|
|
|
#define NEUTRAL_AREA_RADIUS_RATIO 1.3f
|
|
|
|
|
2012-01-31 08:15:43 +00:00
|
|
|
// DEBUG
|
2012-01-30 09:18:30 +00:00
|
|
|
#define INPUTLENGTH_FOR_DEBUG -1
|
2012-01-31 08:15:43 +00:00
|
|
|
#define MIN_OUTPUT_INDEX_FOR_DEBUG -1
|
|
|
|
|
2012-06-14 18:25:50 +00:00
|
|
|
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
|
|
|
TypeName(const TypeName&); \
|
|
|
|
void operator=(const TypeName&)
|
|
|
|
|
|
|
|
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
|
|
|
|
TypeName(); \
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(TypeName)
|
|
|
|
|
2012-06-05 08:55:52 +00:00
|
|
|
// Used as a return value for character comparison
|
|
|
|
typedef enum {
|
|
|
|
// Same char, possibly with different case or accent
|
|
|
|
EQUIVALENT_CHAR,
|
|
|
|
// It is a char located nearby on the keyboard
|
|
|
|
NEAR_PROXIMITY_CHAR,
|
|
|
|
// It is an unrelated char
|
|
|
|
UNRELATED_CHAR,
|
|
|
|
// Additional proximity char which can differ by language.
|
|
|
|
ADDITIONAL_PROXIMITY_CHAR
|
|
|
|
} ProximityType;
|
2010-12-02 05:53:24 +00:00
|
|
|
#endif // LATINIME_DEFINES_H
|