Keisuke Kuroyanagi | cd10540 | 2014-11-10 08:57:07 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | #ifndef LATINIME_DICT_TOOLKIT_OFFDEVICE_INTERMEDIATE_DICT_H |
| 18 | #define LATINIME_DICT_TOOLKIT_OFFDEVICE_INTERMEDIATE_DICT_H |
| 19 | |
| 20 | #include "dict_toolkit_defines.h" |
Keisuke Kuroyanagi | 99754e2 | 2014-11-11 01:00:31 +0900 | [diff] [blame^] | 21 | #include "offdevice_intermediate_dict/offdevice_intermediate_dict_header.h" |
Keisuke Kuroyanagi | cd10540 | 2014-11-10 08:57:07 +0900 | [diff] [blame] | 22 | #include "offdevice_intermediate_dict/offdevice_intermediate_dict_pt_node_array.h" |
| 23 | #include "suggest/core/dictionary/property/word_property.h" |
| 24 | #include "utils/int_array_view.h" |
| 25 | |
| 26 | namespace latinime { |
| 27 | namespace dicttoolkit { |
| 28 | |
| 29 | /** |
| 30 | * On memory patricia trie to represent a dictionary. |
| 31 | */ |
| 32 | class OffdeviceIntermediateDict final { |
| 33 | public: |
Keisuke Kuroyanagi | 99754e2 | 2014-11-11 01:00:31 +0900 | [diff] [blame^] | 34 | OffdeviceIntermediateDict(const OffdeviceIntermediateDictHeader &header) |
| 35 | : mHeader(header), mRootPtNodeArray() {} |
| 36 | |
Keisuke Kuroyanagi | cd10540 | 2014-11-10 08:57:07 +0900 | [diff] [blame] | 37 | bool addWord(const WordProperty &wordProperty); |
| 38 | // The returned value will be invalid after modifying the dictionary. e.g. calling addWord(). |
| 39 | const WordProperty *getWordProperty(const CodePointArrayView codePoints) const; |
Keisuke Kuroyanagi | 99754e2 | 2014-11-11 01:00:31 +0900 | [diff] [blame^] | 40 | const OffdeviceIntermediateDictHeader &getHeader() const { return mHeader; } |
Keisuke Kuroyanagi | cd10540 | 2014-11-10 08:57:07 +0900 | [diff] [blame] | 41 | |
| 42 | private: |
| 43 | DISALLOW_ASSIGNMENT_OPERATOR(OffdeviceIntermediateDict); |
| 44 | |
Keisuke Kuroyanagi | 99754e2 | 2014-11-11 01:00:31 +0900 | [diff] [blame^] | 45 | const OffdeviceIntermediateDictHeader mHeader; |
Keisuke Kuroyanagi | cd10540 | 2014-11-10 08:57:07 +0900 | [diff] [blame] | 46 | OffdeviceIntermediateDictPtNodeArray mRootPtNodeArray; |
| 47 | |
| 48 | bool addWordInner(const CodePointArrayView codePoints, const WordProperty &wordProperty, |
| 49 | OffdeviceIntermediateDictPtNodeArray &ptNodeArray); |
| 50 | }; |
| 51 | |
| 52 | } // namespace dicttoolkit |
| 53 | } // namespace latinime |
| 54 | #endif // LATINIME_DICT_TOOLKIT_OFFDEVICE_INTERMEDIATE_DICT_H |