20 #include "dictionary/datrie.h"
21 #include "dictionary/text.h"
23 Dict* dict_new(
const char* filename, opencc_dictionary_type type) {
25 dictionary->type = type;
27 case OPENCC_DICTIONARY_TYPE_TEXT:
28 dictionary->dict = dict_text_new(filename);
30 case OPENCC_DICTIONARY_TYPE_DATRIE:
31 dictionary->dict = dict_datrie_new(filename);
35 dictionary = (
Dict*)-1;
40 void dict_delete(
Dict* dict) {
42 case OPENCC_DICTIONARY_TYPE_TEXT:
43 dict_text_delete(dict->dict);
45 case OPENCC_DICTIONARY_TYPE_DATRIE:
46 dict_datrie_delete(dict->dict);
49 debug_should_not_be_here();
54 const ucs4_t*
const* dict_match_longest(
Dict* dict,
57 size_t* match_length) {
59 case OPENCC_DICTIONARY_TYPE_TEXT:
60 return dict_text_match_longest(dict->dict,
65 case OPENCC_DICTIONARY_TYPE_DATRIE:
66 return dict_datrie_match_longest(dict->dict,
72 debug_should_not_be_here();
74 return (
const ucs4_t*
const*)-1;
77 size_t dict_get_all_match_lengths(
Dict* dict,
79 size_t* match_length) {
81 case OPENCC_DICTIONARY_TYPE_TEXT:
82 return dict_text_get_all_match_lengths(dict->dict,
86 case OPENCC_DICTIONARY_TYPE_DATRIE:
87 return dict_datrie_get_all_match_lengths(dict->dict,
92 debug_should_not_be_here();