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" 21#include "offdevice_intermediate_dict/offdevice_intermediate_dict_header.h" 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 26namespace latinime { 27namespace dicttoolkit { 28 29/** 30 * On memory patricia trie to represent a dictionary. 31 */ 32class OffdeviceIntermediateDict final { 33 public: 34 OffdeviceIntermediateDict(const OffdeviceIntermediateDictHeader &header) 35 : mHeader(header), mRootPtNodeArray() {} 36 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; 40 const OffdeviceIntermediateDictHeader &getHeader() const { return mHeader; } 41 42 private: 43 DISALLOW_ASSIGNMENT_OPERATOR(OffdeviceIntermediateDict); 44 45 const OffdeviceIntermediateDictHeader mHeader; 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 55