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 13 namespace rime { 14 15 class Dictionary; 16 class Prism; 17 class Table; 18 class ReverseDb; 19 class DictSettings; 20 class EditDistanceCorrector; 21 class EntryCollector; 22 class Vocabulary; 23 class 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_API explicit DictCompiler(Dictionary *dictionary); 35 RIME_API virtual ~DictCompiler(); 36 37 RIME_API bool Compile(const string &schema_file); set_options(int options)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<string>& dict_files, 45 uint32_t dict_file_checksum); 46 bool BuildPrism(const string& 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_ 67