blob: 52191beeaeca928800a074024cf3c80e604ef586 [file] [log] [blame]
satoke808e432010-12-02 14:53:24 +09001/*
2**
3** Copyright 2010, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#ifndef LATINIME_DEFINES_H
19#define LATINIME_DEFINES_H
20
21#ifdef FLAG_DBG
22#include <cutils/log.h>
23#ifndef LOG_TAG
24#define LOG_TAG "LatinIME: "
25#endif
satokcdbbea72010-12-08 16:04:16 +090026#define DEBUG_DICT true
satoka3d78f62010-12-09 22:08:33 +090027#define DEBUG_DICT_FULL true
28#define DEBUG_SHOW_FOUND_WORD DEBUG_DICT_FULL
29#define DEBUG_NODE DEBUG_DICT_FULL
30#define DEBUG_TRACE DEBUG_DICT_FULL
satoke808e432010-12-02 14:53:24 +090031#else // FLAG_DBG
32#define LOGI
satokcdbbea72010-12-08 16:04:16 +090033#define DEBUG_DICT false
satoka3d78f62010-12-09 22:08:33 +090034#define DEBUG_DICT_FULL false
satokcdbbea72010-12-08 16:04:16 +090035#define DEBUG_SHOW_FOUND_WORD false
satokaee09dc2010-12-09 19:21:51 +090036#define DEBUG_NODE false
satoka3d78f62010-12-09 22:08:33 +090037#define DEBUG_TRACE false
satoke808e432010-12-02 14:53:24 +090038#endif // FLAG_DBG
39
satok662fe692010-12-08 17:05:39 +090040#ifndef U_SHORT_MAX
41#define U_SHORT_MAX 1 << 16
42#endif
43
satoke808e432010-12-02 14:53:24 +090044// 22-bit address = ~4MB dictionary size limit, which on average would be about 200k-300k words
45#define ADDRESS_MASK 0x3FFFFF
46
47// The bit that decides if an address follows in the next 22 bits
48#define FLAG_ADDRESS_MASK 0x40
49// The bit that decides if this is a terminal node for a word. The node could still have children,
50// if the word has other endings.
51#define FLAG_TERMINAL_MASK 0x80
52
53#define FLAG_BIGRAM_READ 0x80
54#define FLAG_BIGRAM_CHILDEXIST 0x40
55#define FLAG_BIGRAM_CONTINUED 0x80
56#define FLAG_BIGRAM_FREQ 0x7F
57
58#define DICTIONARY_VERSION_MIN 200
59#define DICTIONARY_HEADER_SIZE 2
60#define NOT_VALID_WORD -99
61
satok662fe692010-12-08 17:05:39 +090062#define SUGGEST_WORDS_WITH_MISSING_CHARACTER true
63#define SUGGEST_WORDS_WITH_MISSING_SPACE_CHARACTER true
64#define SUGGEST_WORDS_WITH_EXCESSIVE_CHARACTER true
satoka3d78f62010-12-09 22:08:33 +090065#define SUGGEST_WORDS_WITH_TRANSPOSED_CHARACTERS true
66
67#define WORDS_WITH_MISSING_CHARACTER_DEMOTION_RATE 75
68#define WORDS_WITH_MISSING_SPACE_CHARACTER_DEMOTION_RATE 80
69#define WORDS_WITH_EXCESSIVE_CHARACTER_DEMOTION_RATE 75
70#define WORDS_WITH_TRANSPOSED_CHARACTERS_DEMOTION_RATE 60
satoke808e432010-12-02 14:53:24 +090071
satokf5cded12010-12-06 21:28:24 +090072// This should be greater than or equal to MAX_WORD_LENGTH defined in BinaryDictionary.java
73// This is only used for the size of array. Not to be used in c functions.
74#define MAX_WORD_LENGTH_INTERNAL 48
satok715514d2010-12-02 20:19:59 +090075
satok68319262010-12-03 19:38:08 +090076#define MAX_DEPTH_MULTIPLIER 3
77
satok662fe692010-12-08 17:05:39 +090078#define MIN_SUGGEST_DEPTH 2
79
satokf5cded12010-12-06 21:28:24 +090080#define min(a,b) ((a)<(b)?(a):(b))
81
satoke808e432010-12-02 14:53:24 +090082#endif // LATINIME_DEFINES_H