diff options
author | Peng Wu <alexepico@gmail.com> | 2017-01-22 16:07:51 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2017-01-22 16:12:32 +0800 |
commit | 07f2e2ed842b500ecd717ce2eff63f08d77a800c (patch) | |
tree | 9eefbd6febfc4d453fafc0db66abea62505438de /src/lookup | |
parent | 29ac48475fe23f6f2cf3b3b9677b3902b9cf8f0b (diff) | |
download | libpinyin-07f2e2ed842b500ecd717ce2eff63f08d77a800c.tar.gz libpinyin-07f2e2ed842b500ecd717ce2eff63f08d77a800c.tar.xz libpinyin-07f2e2ed842b500ecd717ce2eff63f08d77a800c.zip |
write constructors
Diffstat (limited to 'src/lookup')
-rw-r--r-- | src/lookup/phonetic_lookup.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/lookup/phonetic_lookup.h b/src/lookup/phonetic_lookup.h index 94a9863..50e5fbe 100644 --- a/src/lookup/phonetic_lookup.h +++ b/src/lookup/phonetic_lookup.h @@ -418,6 +418,16 @@ protected: FacadePhraseIndex * m_phrase_index; public: + ForwardPhoneticConstraints() { + m_constraints = g_array_new(TRUE, TRUE, sizeof(trellis_constraint_t)); + } + + ~ForwardPhoneticConstraints() { + g_array_free(m_constraints, TRUE); + m_constraints = NULL; + } + +public: int add_constraint(size_t start, size_t end, phrase_token_t token); bool clear_constraint(size_t index); bool validate_constraint(PhoneticKeyMatrix * matrix); @@ -632,6 +642,33 @@ protected: public: + PhoneticLookup(const gfloat lambda, + FacadeChewingTable2 * pinyin_table, + FacadePhraseIndex * phrase_index, + Bigram * system_bigram, + Bigram * user_bigram) + : bigram_lambda(lambda), + unigram_lambda(1. - lambda) + { + /* store the pointer. */ + m_pinyin_table = pinyin_table; + m_phrase_index = phrase_index; + m_system_bigram = system_bigram; + m_user_bigram = user_bigram; + + m_cached_keys = g_array_new(TRUE, TRUE, sizeof(ChewingKey)); + + /* the member variables below are saved in get_nbest_match call. */ + m_matrix = NULL; + m_constraints = NULL; + } + + ~PhoneticLookup(){ + g_array_free(m_cached_keys, TRUE); + m_cached_keys = NULL; + } + + bool get_nbest_match(TokenVector prefixes, PhoneticKeyMatrix * matrix, ForwardPhoneticConstraints constraints, |