diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pinyin.cpp | 58 | ||||
-rw-r--r-- | src/pinyin.h | 3 |
2 files changed, 61 insertions, 0 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp index 134c450..316e42d 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -5,3 +5,61 @@ /* Note: will implement a glue layer for input method integration. * Refer to: fcitx-sunpinyin */ + +struct _pinyin_context_t{ + PinyinDefaultParser * m_default_parser; + PinyinShuangPinParser * m_shuang_pin_parser; + PinyinCustomSettings * m_custom; + + PinyinLargeTable * m_pinyin_table; + PhraseLargeTable * m_phrase_table; + FacadePhraseIndex * m_phrase_index; + Bigram * m_system_bigram; + Bigram * m_user_bigram; + PinyinLookup * m_pinyin_lookup; + + BitmapPinyinValidator * m_validator; + const char * m_system_dir; + const char * m_user_dir; +}; + +pinyin_context_t * pinyin_init(const char * systemdir, const char * userdir); +void pinyin_fini(pinyin_context_t * context); + +/* copy from custom to context->m_custom. */ +bool pinyin_set_options(pinyin_context_t * context, + PinyinCustomSettings * custom); +bool pinyin_set_pinyin_keys(pinyin_context_t * context, + PinyinKeyVector pinyin_keys); + + +/* the returned sentence should be freed by g_free(). */ +bool pinyin_get_guessed_setence(pinyin_context_t * context, + char ** sentence); + +bool pinyin_parse_one(pinyin_context_t * context, + const char * onepinyin, + PinyinKey * onekey); +bool pinyin_parse_more(pinyin_context_t * context, + const char * pinyins, + PinyinKeyVector pinyin_keys); + +bool pinyin_get_candidates(pinyin_context_t * context, + size_t offset, TokenVector tokens); +bool pinyin_choose_candidate(pinyin_context_t * context, + size_t offset, phrase_token_t * token); + +/* the returned word should be freed by g_free. */ +bool pinyin_translate_token(pinyin_context_t * context, + phrase_token_t token, char ** word); + +bool pinyin_train(pinyin_context_t * context); +bool pinyin_save(pinyin_context_t * context); + +bool pinyin_reset(pinyin_context_t * context); + +/** TODO: to be implemented. + * bool pinyin_get_guessed_sentence_with_prefix(...); + * bool pinyin_get_candidates_with_prefix(...); + * For context-dependent order of the candidates list. + */ diff --git a/src/pinyin.h b/src/pinyin.h index 6e3c81e..d050f21 100644 --- a/src/pinyin.h +++ b/src/pinyin.h @@ -14,3 +14,6 @@ /* training module */ #include "flexible_ngram.h" + +typedef MatchResults TokenVector; +typedef struct _pinyin_context_t pinyin_context_t; |