Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: third_party/prediction/suggest/policyimpl/dictionary/structure/v4/ver4_dict_constants.cpp

Issue 1247903003: Add spellcheck and word suggestion to the prediction service (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "third_party/prediction/suggest/policyimpl/dictionary/structure/v4/ver4 _dict_constants.h"
18
19 namespace latinime {
20
21 const char* const Ver4DictConstants::BODY_FILE_EXTENSION = ".body";
22 const char* const Ver4DictConstants::HEADER_FILE_EXTENSION = ".header";
23
24 // Version 4 dictionary size is implicitly limited to 8MB due to 3-byte offsets.
25 const int Ver4DictConstants::MAX_DICTIONARY_SIZE = 8 * 1024 * 1024;
26 // Extended region size, which is not GCed region size in dict file + additional
27 // buffer size, is
28 // limited to 1MB to prevent from inefficient traversing.
29 const int Ver4DictConstants::MAX_DICT_EXTENDED_REGION_SIZE = 1 * 1024 * 1024;
30
31 // NUM_OF_BUFFERS_FOR_SINGLE_DICT_CONTENT for Trie and
32 // TerminalAddressLookupTable.
33 // NUM_OF_BUFFERS_FOR_LANGUAGE_MODEL_DICT_CONTENT for language model.
34 // NUM_OF_BUFFERS_FOR_SPARSE_TABLE_DICT_CONTENT for bigram and shortcut.
35 const size_t Ver4DictConstants::NUM_OF_CONTENT_BUFFERS_IN_BODY_FILE =
36 NUM_OF_BUFFERS_FOR_SINGLE_DICT_CONTENT * 2 +
37 NUM_OF_BUFFERS_FOR_LANGUAGE_MODEL_DICT_CONTENT +
38 NUM_OF_BUFFERS_FOR_SPARSE_TABLE_DICT_CONTENT * 2;
39 const int Ver4DictConstants::TRIE_BUFFER_INDEX = 0;
40 const int Ver4DictConstants::TERMINAL_ADDRESS_LOOKUP_TABLE_BUFFER_INDEX =
41 TRIE_BUFFER_INDEX + NUM_OF_BUFFERS_FOR_SINGLE_DICT_CONTENT;
42 const int Ver4DictConstants::LANGUAGE_MODEL_BUFFER_INDEX =
43 TERMINAL_ADDRESS_LOOKUP_TABLE_BUFFER_INDEX +
44 NUM_OF_BUFFERS_FOR_SINGLE_DICT_CONTENT;
45 const int Ver4DictConstants::BIGRAM_BUFFERS_INDEX =
46 LANGUAGE_MODEL_BUFFER_INDEX +
47 NUM_OF_BUFFERS_FOR_LANGUAGE_MODEL_DICT_CONTENT;
48 const int Ver4DictConstants::SHORTCUT_BUFFERS_INDEX =
49 BIGRAM_BUFFERS_INDEX + NUM_OF_BUFFERS_FOR_SPARSE_TABLE_DICT_CONTENT;
50
51 const int Ver4DictConstants::NOT_A_TERMINAL_ID = -1;
52 const int Ver4DictConstants::PROBABILITY_SIZE = 1;
53 const int Ver4DictConstants::FLAGS_IN_PROBABILITY_FILE_SIZE = 1;
54 const int Ver4DictConstants::TERMINAL_ADDRESS_TABLE_ADDRESS_SIZE = 3;
55 const int Ver4DictConstants::NOT_A_TERMINAL_ADDRESS = 0;
56 const int Ver4DictConstants::TERMINAL_ID_FIELD_SIZE = 4;
57 const int Ver4DictConstants::TIME_STAMP_FIELD_SIZE = 4;
58 const int Ver4DictConstants::WORD_LEVEL_FIELD_SIZE = 1;
59 const int Ver4DictConstants::WORD_COUNT_FIELD_SIZE = 1;
60
61 const int Ver4DictConstants::BIGRAM_ADDRESS_TABLE_BLOCK_SIZE = 16;
62 const int Ver4DictConstants::BIGRAM_ADDRESS_TABLE_DATA_SIZE = 4;
63 const int Ver4DictConstants::SHORTCUT_ADDRESS_TABLE_BLOCK_SIZE = 64;
64 const int Ver4DictConstants::SHORTCUT_ADDRESS_TABLE_DATA_SIZE = 4;
65
66 const int Ver4DictConstants::BIGRAM_TARGET_TERMINAL_ID_FIELD_SIZE = 3;
67 // Unsigned int max value of BIGRAM_TARGET_TERMINAL_ID_FIELD_SIZE-byte is used
68 // for representing
69 // invalid terminal ID in bigram lists.
70 const int Ver4DictConstants::INVALID_BIGRAM_TARGET_TERMINAL_ID =
71 (1 << (BIGRAM_TARGET_TERMINAL_ID_FIELD_SIZE * 8)) - 1;
72 const int Ver4DictConstants::BIGRAM_FLAGS_FIELD_SIZE = 1;
73 const int Ver4DictConstants::BIGRAM_PROBABILITY_MASK = 0x0F;
74 const int Ver4DictConstants::BIGRAM_IS_LINK_MASK = 0x80;
75 const int Ver4DictConstants::BIGRAM_LARGE_PROBABILITY_FIELD_SIZE = 1;
76
77 const int Ver4DictConstants::SHORTCUT_FLAGS_FIELD_SIZE = 1;
78 const int Ver4DictConstants::SHORTCUT_PROBABILITY_MASK = 0x0F;
79 const int Ver4DictConstants::SHORTCUT_HAS_NEXT_MASK = 0x80;
80
81 const size_t Ver4DictConstants::NUM_OF_BUFFERS_FOR_SINGLE_DICT_CONTENT = 1;
82 const size_t Ver4DictConstants::NUM_OF_BUFFERS_FOR_SPARSE_TABLE_DICT_CONTENT =
83 3;
84 const size_t Ver4DictConstants::NUM_OF_BUFFERS_FOR_LANGUAGE_MODEL_DICT_CONTENT =
85 1;
86
87 } // namespace latinime
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698