librime: dict_compiler.h Source File

| librime 1.2 Rime Input Method Engine, the core library

dict_compiler.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2011-11-27 GONG Chen <chen.sst@gmail.com>
6//
7#ifndef RIME_DICT_COMPILER_H_
8#define RIME_DICT_COMPILER_H_
9
10#include <rime_api.h>
11#include <rime/common.h>
12
13namespace rime {
14
15class Dictionary;
16class Prism;
17class Table;
18class ReverseDb;
19class DictSettings;
20class EditDistanceCorrector;
21class EntryCollector;
22class Vocabulary;
23class ResourceResolver;
24
25 class DictCompiler {
26 public:
27 enum Options {
28 kRebuildPrism = 1,
29 kRebuildTable = 2,
30 kRebuild = kRebuildPrism | kRebuildTable,
31 kDump = 4,
32 };
33
34 RIME_DLL explicit DictCompiler(Dictionary* dictionary);
35 RIME_DLL virtual ~DictCompiler();
36
37 RIME_DLL bool Compile(const path& schema_file);
38 void set_options(int options) { options_ = options; }
39
40 private:
41 bool BuildTable(int table_index,
42 EntryCollector& collector,
43 DictSettings* settings,
44 const vector<path>& dict_files,
45 uint32_t dict_file_checksum);
46 bool BuildPrism(const path& schema_file,
47 uint32_t dict_file_checksum,
48 uint32_t schema_file_checksum);
49 bool BuildReverseDb(DictSettings* settings,
50 const EntryCollector& collector,
51 const Vocabulary& vocabulary,
52 uint32_t dict_file_checksum);
53
54 const string& dict_name_;
55 const vector<string>& packs_;
56 an<Prism> prism_;
57 an<EditDistanceCorrector> correction_;
58 vector<of<Table>> tables_;
59 int options_ = 0;
60 the<ResourceResolver> source_resolver_;
61 the<ResourceResolver> target_resolver_;
62};
63
64} // namespace rime
65
66#endif // RIME_DICT_COMPILER_H_
common.h
rime_api.h
RIME_DLL
#define RIME_DLL
Definition rime_api.h:33
rime
Definition algebra.cc:12
rime::an
std::shared_ptr< T > an
Definition common.h:60
rime::the
std::unique_ptr< T > the
Definition common.h:58
rime::dictionary
Definition dictionary.cc:19
rime::path
Definition common.h:84
rime::EditDistanceCorrector
Definition corrector.h:94
rime::DictCompiler
Definition dict_compiler.h:25
rime::DictCompiler::Options
Options
Definition dict_compiler.h:27
rime::DictCompiler::kRebuild
@ kRebuild
Definition dict_compiler.h:30
rime::DictCompiler::kRebuildPrism
@ kRebuildPrism
Definition dict_compiler.h:28
rime::DictCompiler::kRebuildTable
@ kRebuildTable
Definition dict_compiler.h:29
rime::DictCompiler::kDump
@ kDump
Definition dict_compiler.h:31
rime::DictCompiler::Compile
RIME_DLL bool Compile(const path &schema_file)
Definition dict_compiler.cc:80
rime::DictCompiler::set_options
void set_options(int options)
Definition dict_compiler.h:38
rime::DictCompiler::DictCompiler
RIME_DLL DictCompiler(Dictionary *dictionary)
Definition dict_compiler.cc:27
rime::DictSettings
Definition dict_settings.h:16
rime::Dictionary
Definition dictionary.h:62
rime::EntryCollector
Definition entry_collector.h:36
rime::Prism
Definition prism.h:67
rime::ReverseDb
Definition reverse_lookup_dictionary.h:40
rime::Table
Definition table.h:191
rime::Vocabulary
Definition vocabulary.h:100
rime::ResourceResolver
Definition resource.h:22