diff options
author | Peng Wu <alexepico@gmail.com> | 2017-01-11 11:06:06 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2017-01-11 11:06:06 +0800 |
commit | 52d19b8fad55df8e539af75bf5552488dd2a53e3 (patch) | |
tree | e0d790806419446bdcb975a3208436a9dd1e3c7b /src/lookup/phonetic_lookup.h | |
parent | fc9efc97091cd0a1b537ca65d4dc161ce3bf5779 (diff) | |
download | libpinyin-52d19b8fad55df8e539af75bf5552488dd2a53e3.tar.gz libpinyin-52d19b8fad55df8e539af75bf5552488dd2a53e3.tar.xz libpinyin-52d19b8fad55df8e539af75bf5552488dd2a53e3.zip |
write phonetic_lookup_linear.h
Diffstat (limited to 'src/lookup/phonetic_lookup.h')
-rw-r--r-- | src/lookup/phonetic_lookup.h | 87 |
1 files changed, 2 insertions, 85 deletions
diff --git a/src/lookup/phonetic_lookup.h b/src/lookup/phonetic_lookup.h index 5de61e8..f571fa5 100644 --- a/src/lookup/phonetic_lookup.h +++ b/src/lookup/phonetic_lookup.h @@ -51,49 +51,6 @@ struct trellis_value_t { } }; -template <gint32 nbest> -struct trellis_node { -private: - gint32 m_nelem; - trellis_value_t m_elements[nbest]; - -public: - trellis_node(){ - m_nelem = 0; - /* always assume non-used m_elements contains random data. */ - } - -public: - gint32 length() { return m_nelem; } - const trellis_value_t * begin() { return m_elements; } - const trellis_value_t * end() { return m_elements + m_nelem; } - - /* return true if the item is stored into m_elements. */ - bool eval_item(const trellis_value_t * item) { - /* still have space */ - if (m_nelem < nbest) { - m_elements[m_nelem] = *item; - m_nelem ++; - return true; - } - - /* find minium item */ - trellis_value_t * min = m_elements; - for (gint32 i = 1; i < m_nelem; ++i) { - if (min->m_poss > m_elements[i].m_poss) - min = m_elements + i; - } - - /* compare new item */ - if (item->m_poss > min->m_poss) { - *min = *item; - return true; - } - - return false; - } -}; - struct matrix_value_t { phrase_token_t m_cur_token; gfloat m_poss; @@ -111,48 +68,8 @@ struct matrix_value_t { } }; -template <gint32 nbest> -struct matrix_step { -private: - gint32 m_nelem; - matrix_value_t m_elements[nbest]; - -public: - matrix_step(){ - m_nelem = 0; - /* always assume non-used m_elements contains random data. */ - } - -public: - gint32 length() { return m_nelem; } - const matrix_value_t * begin() { return m_elements; } - const matrix_value_t * end() { return m_elements + m_nelem; } - - /* return true if the item is stored into m_elements. */ - bool eval_item(const trellis_value_t * item) { - /* still have space */ - if (m_nelem < nbest) { - m_elements[m_nelem] = *item; - m_nelem ++; - return true; - } - - /* find minium item */ - matrix_value_t * min = m_elements; - for (gint32 i = 1; i < m_nelem; ++i) { - if (min->m_poss > m_elements[i].m_poss) - min = m_elements + i; - } - - /* compare new item */ - if (item->m_poss > min->m_poss) { - *min = *item; - return true; - } - - return false; - } -}; +/* for debug purpose */ +#include "phonetic_lookup_linear.h" struct trellis_constraint_t { /* the constraint type */ |