diff options
author | Peng Wu <alexepico@gmail.com> | 2017-02-07 13:38:09 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2017-02-07 13:38:09 +0800 |
commit | 55d7fed35b663fa4acadc42e24a2175c228f7c37 (patch) | |
tree | 23502de338082c99c8e684f34ad46a8c58f90c8a /src | |
parent | 8df49857ef632ab03c290df8ee6abe9f436d1d3c (diff) | |
download | libpinyin-55d7fed35b663fa4acadc42e24a2175c228f7c37.tar.gz libpinyin-55d7fed35b663fa4acadc42e24a2175c228f7c37.tar.xz libpinyin-55d7fed35b663fa4acadc42e24a2175c228f7c37.zip |
fixes compile again
Diffstat (limited to 'src')
-rw-r--r-- | src/lookup/phonetic_lookup.cpp | 3 | ||||
-rw-r--r-- | src/lookup/phonetic_lookup.h | 14 | ||||
-rw-r--r-- | src/storage/phonetic_key_matrix.cpp | 12 | ||||
-rw-r--r-- | src/storage/phonetic_key_matrix.h | 18 |
4 files changed, 24 insertions, 23 deletions
diff --git a/src/lookup/phonetic_lookup.cpp b/src/lookup/phonetic_lookup.cpp index 417ee9f..817f837 100644 --- a/src/lookup/phonetic_lookup.cpp +++ b/src/lookup/phonetic_lookup.cpp @@ -22,9 +22,6 @@ namespace pinyin{ -/* internal definition */ -static const size_t nbeam = 32; - bool dump_max_value(GPtrArray * values){ if (0 == values->len) return false; diff --git a/src/lookup/phonetic_lookup.h b/src/lookup/phonetic_lookup.h index 078a467..6c349fb 100644 --- a/src/lookup/phonetic_lookup.h +++ b/src/lookup/phonetic_lookup.h @@ -31,6 +31,10 @@ namespace pinyin{ + +/* internal definition */ +static const size_t nbeam = 32; + #define LONG_SENTENCE_PENALTY 1.2 struct trellis_value_t { @@ -278,8 +282,8 @@ public: node->number(); const trellis_value_t * value = node->begin(); - for (size_t j = 0; j < node->length(); ++j) { - g_ptr_array_add(candidates, value); + for (gint32 j = 0; j < node->length(); ++j) { + g_ptr_array_add(candidates, (trellis_value_t *)value); } } @@ -325,7 +329,7 @@ public: get_candidates(tail_index, candidates); get_top_results<nbest>(nbest, tails, candidates); - g_ptr_array_sort(tails, trellis_value_compare); + g_ptr_array_sort(tails, (GCompareFunc)trellis_value_compare); g_ptr_array_free(candidates, TRUE); return true; @@ -749,7 +753,7 @@ public: continue; m_trellis.get_candidates(i, candidates); - get_top_results<nbest>(topresults, candidates); + get_top_results<nbest>(nbeam, topresults, candidates); if (0 == topresults->len) continue; @@ -812,7 +816,7 @@ public: const trellis_value_t * tail = (const trellis_value_t *) g_ptr_array_index(tails, i); - assert(extract_result<nbest>(m_trellis, tail, result)); + assert(extract_result<nbest>(&m_trellis, tail, result)); results->add_result(result); } diff --git a/src/storage/phonetic_key_matrix.cpp b/src/storage/phonetic_key_matrix.cpp index 543da5b..c6f07f6 100644 --- a/src/storage/phonetic_key_matrix.cpp +++ b/src/storage/phonetic_key_matrix.cpp @@ -348,8 +348,8 @@ bool dump_matrix(PhoneticKeyMatrix * matrix) { } int search_matrix_recur(GArray * cached_keys, - FacadeChewingTable2 * table, - PhoneticKeyMatrix * matrix, + const FacadeChewingTable2 * table, + const PhoneticKeyMatrix * matrix, size_t start, size_t end, PhraseIndexRanges ranges, size_t & longest) { @@ -407,8 +407,8 @@ int search_matrix_recur(GArray * cached_keys, return result; } -int search_matrix(FacadeChewingTable2 * table, - PhoneticKeyMatrix * matrix, +int search_matrix(const FacadeChewingTable2 * table, + const PhoneticKeyMatrix * matrix, size_t start, size_t end, PhraseIndexRanges ranges) { assert(end < matrix->size()); @@ -437,7 +437,7 @@ int search_matrix(FacadeChewingTable2 * table, return result; } -gfloat compute_pronunciation_possibility_recur(PhoneticKeyMatrix * matrix, +gfloat compute_pronunciation_possibility_recur(const PhoneticKeyMatrix * matrix, size_t start, size_t end, GArray * cached_keys, PhraseItem & item){ @@ -490,7 +490,7 @@ gfloat compute_pronunciation_possibility_recur(PhoneticKeyMatrix * matrix, return result; } -gfloat compute_pronunciation_possibility(PhoneticKeyMatrix * matrix, +gfloat compute_pronunciation_possibility(const PhoneticKeyMatrix * matrix, size_t start, size_t end, GArray * cached_keys, PhraseItem & item){ diff --git a/src/storage/phonetic_key_matrix.h b/src/storage/phonetic_key_matrix.h index 62edf73..968b969 100644 --- a/src/storage/phonetic_key_matrix.h +++ b/src/storage/phonetic_key_matrix.h @@ -77,7 +77,7 @@ public: } /* Array of Item. */ - bool get_items(size_t index, GArray * items) { + bool get_items(size_t index, GArray * items) const { g_array_set_size(items, 0); if (index >= m_table_content->len) @@ -99,7 +99,7 @@ public: return true; } - size_t get_column_size(size_t index) { + size_t get_column_size(size_t index) const { assert(index < m_table_content->len); GArray * column = (GArray *) @@ -107,7 +107,7 @@ public: return column->len; } - bool get_item(size_t index, size_t row, Item & item) { + bool get_item(size_t index, size_t row, Item & item) const { assert(index < m_table_content->len); GArray * column = (GArray *) @@ -141,7 +141,7 @@ public: } /* Array of keys and key rests. */ - bool get_items(size_t index, GArray * keys, GArray * key_rests) { + bool get_items(size_t index, GArray * keys, GArray * key_rests) const { bool result = m_keys.get_items(index, keys) && m_key_rests.get_items(index, key_rests); @@ -155,14 +155,14 @@ public: m_key_rests.append(index, key_rest); } - size_t get_column_size(size_t index) { + size_t get_column_size(size_t index) const { const size_t size = m_keys.get_column_size(index); assert(size == m_key_rests.get_column_size(index)); return size; } bool get_item(size_t index, size_t row, - ChewingKey & key, ChewingKeyRest & key_rest) { + ChewingKey & key, ChewingKeyRest & key_rest) const { return m_keys.get_item(index, row, key) && m_key_rests.get_item(index, row, key_rest); } @@ -207,12 +207,12 @@ bool fuzzy_syllable_step(pinyin_option_t options, bool dump_matrix(PhoneticKeyMatrix * matrix); -int search_matrix(FacadeChewingTable2 * table, - PhoneticKeyMatrix * matrix, +int search_matrix(const FacadeChewingTable2 * table, + const PhoneticKeyMatrix * matrix, size_t start, size_t end, PhraseIndexRanges ranges); -gfloat compute_pronunciation_possibility(PhoneticKeyMatrix * matrix, +gfloat compute_pronunciation_possibility(const PhoneticKeyMatrix * matrix, size_t start, size_t end, GArray * cached_keys, PhraseItem & item); |