blob: 13d26ba91ce58bf5ed1bb08af004783368aeaca2 [file] [log] [blame]
Keisuke Kuroyanagicd105402014-11-10 08:57:07 +09001/*
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 Kuroyanagi99754e22014-11-11 01:00:31 +090021#include "offdevice_intermediate_dict/offdevice_intermediate_dict_header.h"
Keisuke Kuroyanagicd105402014-11-10 08:57:07 +090022#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:
Keisuke Kuroyanagi99754e22014-11-11 01:00:31 +090034 OffdeviceIntermediateDict(const OffdeviceIntermediateDictHeader &header)
35 : mHeader(header), mRootPtNodeArray() {}
36
Keisuke Kuroyanagicd105402014-11-10 08:57:07 +090037 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 Kuroyanagi99754e22014-11-11 01:00:31 +090040 const OffdeviceIntermediateDictHeader &getHeader() const { return mHeader; }
Keisuke Kuroyanagicd105402014-11-10 08:57:07 +090041
42 private:
43 DISALLOW_ASSIGNMENT_OPERATOR(OffdeviceIntermediateDict);
44
Keisuke Kuroyanagi99754e22014-11-11 01:00:31 +090045 const OffdeviceIntermediateDictHeader mHeader;
Keisuke Kuroyanagicd105402014-11-10 08:57:07 +090046 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