summaryrefslogtreecommitdiffstats
path: root/src/lookup
diff options
context:
space:
mode:
Diffstat (limited to 'src/lookup')
-rw-r--r--src/lookup/phonetic_lookup.h34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/lookup/phonetic_lookup.h b/src/lookup/phonetic_lookup.h
index 6ca7d4f..65602c7 100644
--- a/src/lookup/phonetic_lookup.h
+++ b/src/lookup/phonetic_lookup.h
@@ -117,8 +117,38 @@ private:
GPtrArray * m_steps_content;
public:
- bool clear();
- bool prepare(gint32 nstep);
+ bool clear() {
+ /* clear m_steps_index */
+ for ( size_t i = 0; i < m_steps_index->len; ++i){
+ GHashTable * table = (GHashTable *) g_ptr_array_index(m_steps_index, i);
+ g_hash_table_destroy(table);
+ g_ptr_array_index(m_steps_index, i) = NULL;
+ }
+
+ /* clear m_steps_content */
+ for ( size_t i = 0; i < m_steps_content->len; ++i){
+ GArray * array = (GArray *) g_ptr_array_index(m_steps_content, i);
+ g_array_free(array, TRUE);
+ g_ptr_array_index(m_steps_content, i) = NULL;
+ }
+
+ return true;
+ }
+
+ bool prepare(gint32 nstep) {
+ /* add null start step */
+ g_ptr_array_set_size(m_steps_index, nstep);
+ g_ptr_array_set_size(m_steps_content, nstep);
+
+ for (int i = 0; i < nstep; ++i) {
+ /* initialize m_steps_index */
+ g_ptr_array_index(m_steps_index, i) = g_hash_table_new(g_direct_hash, g_direct_equal);
+ /* initialize m_steps_content */
+ g_ptr_array_index(m_steps_content, i) = g_array_new(FALSE, FALSE, sizeof(trellis_node<nbest>));
+ }
+
+ return true;
+ }
/* Array of phrase_token_t */
bool fill_prefixes(/* in */ TokenVector prefixes);