diff options
-rw-r--r-- | src/include/stl_lite.h | 3 | ||||
-rw-r--r-- | src/lookup/phonetic_lookup.h | 5 | ||||
-rw-r--r-- | src/lookup/phonetic_lookup_heap.h | 19 | ||||
-rw-r--r-- | src/lookup/phonetic_lookup_linear.h | 1 |
4 files changed, 24 insertions, 4 deletions
diff --git a/src/include/stl_lite.h b/src/include/stl_lite.h index 5ad977d..80ffa89 100644 --- a/src/include/stl_lite.h +++ b/src/include/stl_lite.h @@ -41,5 +41,8 @@ namespace std_lite{ using std::pop_heap; + using std::push_heap; + + } #endif diff --git a/src/lookup/phonetic_lookup.h b/src/lookup/phonetic_lookup.h index 6c349fb..6b88804 100644 --- a/src/lookup/phonetic_lookup.h +++ b/src/lookup/phonetic_lookup.h @@ -107,7 +107,7 @@ struct matrix_value_t { }; #endif -#if 1 +#if 0 /* for debug purpose */ #include "phonetic_lookup_linear.h" #else @@ -191,7 +191,9 @@ public: ~ForwardPhoneticTrellis() { clear(); g_ptr_array_free(m_steps_index, TRUE); + m_steps_index = NULL; g_ptr_array_free(m_steps_content, TRUE); + m_steps_content = NULL; } public: @@ -460,6 +462,7 @@ public: ~NBestMatchResults() { clear(); g_ptr_array_free(m_results, TRUE); + m_results = NULL; } public: diff --git a/src/lookup/phonetic_lookup_heap.h b/src/lookup/phonetic_lookup_heap.h index 13a2360..25e69fe 100644 --- a/src/lookup/phonetic_lookup_heap.h +++ b/src/lookup/phonetic_lookup_heap.h @@ -54,13 +54,14 @@ public: /* return true if the item is stored into m_elements. */ bool eval_item(const trellis_value_t * item) { + /* min heap here, and always push heap. */ /* still have space */ if (m_nelem < nbest) { m_elements[m_nelem] = *item; m_nelem ++; - push_heap(begin(), end(), trellis_value_more_than<nbest>); + std_lite::push_heap(m_elements, m_elements + m_nelem, trellis_value_more_than<nbest>); return true; } @@ -69,9 +70,9 @@ public: /* compare new item */ if (item->m_poss > min->m_poss) { - pop_heap(begin(), end(), trellis_value_more_than<nbest>); + std_lite::pop_heap(m_elements, m_elements + m_nelem, trellis_value_more_than<nbest>); m_elements[m_nelem - 1] = *item; - push_heap(begin(), end(), trellis_value_more_than<nbest>); + std_lite::push_heap(m_elements, m_elements + m_nelem, trellis_value_more_than<nbest>); return true; } @@ -97,8 +98,20 @@ public: const trellis_value_t * begin() { return &m_element; } const trellis_value_t * end() { return &m_element + 1; } + bool number() { + m_element.m_current_index = 0; + return true; + } + /* return true if the item is stored into m_element. */ bool eval_item(const trellis_value_t * item) { + + /* no item yet. */ + if (0 == m_element.m_sentence_length) { + m_element = *item; + return true; + } + if (trellis_value_less_than<1>(&m_element, item)) { m_element = *item; return true; diff --git a/src/lookup/phonetic_lookup_linear.h b/src/lookup/phonetic_lookup_linear.h index 2ce8369..5a9f07b 100644 --- a/src/lookup/phonetic_lookup_linear.h +++ b/src/lookup/phonetic_lookup_linear.h @@ -46,6 +46,7 @@ public: /* 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; |