summaryrefslogtreecommitdiffstats
path: root/tests/storage/test_chewing_table.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-05-24 16:09:40 +0800
committerPeng Wu <alexepico@gmail.com>2016-05-24 16:09:40 +0800
commitb92ec5fc578b73479861b7da9e4524fc8998df2d (patch)
tree2f354a84a0ad72716eb0fe371c05bc6457312118 /tests/storage/test_chewing_table.cpp
parent0d2c765a160775f1b97be83c3bd8a045b7b5600a (diff)
downloadlibpinyin-b92ec5fc578b73479861b7da9e4524fc8998df2d.zip
libpinyin-b92ec5fc578b73479861b7da9e4524fc8998df2d.tar.gz
libpinyin-b92ec5fc578b73479861b7da9e4524fc8998df2d.tar.xz
write dump_ranges function
Diffstat (limited to 'tests/storage/test_chewing_table.cpp')
-rw-r--r--tests/storage/test_chewing_table.cpp53
1 files changed, 3 insertions, 50 deletions
diff --git a/tests/storage/test_chewing_table.cpp b/tests/storage/test_chewing_table.cpp
index c0a1ae7..7a819b9 100644
--- a/tests/storage/test_chewing_table.cpp
+++ b/tests/storage/test_chewing_table.cpp
@@ -96,58 +96,11 @@ int main(int argc, char * argv[]) {
phrase_index.clear_ranges(ranges);
largetable.search(keys->len, (ChewingKey *)keys->data, ranges);
- for (i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
- GArray * & range = ranges[i];
- if (!range)
- continue;
-
- if (range->len)
- printf("range items number:%d\n", range->len);
-
- for (size_t k = 0; k < range->len; ++k) {
- PhraseIndexRange * onerange =
- &g_array_index(range, PhraseIndexRange, k);
- printf("start:%d\tend:%d\n", onerange->m_range_begin,
- onerange->m_range_end);
-
- PhraseItem item;
- for ( phrase_token_t token = onerange->m_range_begin;
- token != onerange->m_range_end; ++token){
-
- phrase_index.get_phrase_item( token, item);
-
- /* get phrase string */
- ucs4_t buffer[MAX_PHRASE_LENGTH + 1];
- item.get_phrase_string(buffer);
- char * string = g_ucs4_to_utf8
- ( buffer, item.get_phrase_length(),
- NULL, NULL, NULL);
- printf("%s\t", string);
- g_free(string);
-
- ChewingKey chewing_buffer[MAX_PHRASE_LENGTH];
- size_t npron = item.get_n_pronunciation();
- guint32 freq;
- for (size_t m = 0; m < npron; ++m){
- item.get_nth_pronunciation(m, chewing_buffer, freq);
- for (size_t n = 0; n < item.get_phrase_length();
- ++n){
- gchar * pinyins =
- chewing_buffer[n].get_pinyin_string();
- printf("%s'", pinyins);
- g_free(pinyins);
- }
- printf("\b\t%d\t", freq);
- }
- }
- printf("\n");
- }
- g_array_set_size(range, 0);
- }
+ dump_ranges(&phrase_index, ranges);
phrase_index.destroy_ranges(ranges);
- g_array_free(keys, TRUE);
- g_array_free(key_rests, TRUE);
+ g_array_free(keys, TRUE);
+ g_array_free(key_rests, TRUE);
}
if (linebuf)