diff options
-rw-r--r-- | tests/storage/test_pinyin_table.cpp | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/tests/storage/test_pinyin_table.cpp b/tests/storage/test_pinyin_table.cpp index 42da434..fbd00f8 100644 --- a/tests/storage/test_pinyin_table.cpp +++ b/tests/storage/test_pinyin_table.cpp @@ -4,7 +4,6 @@ #include "novel_types.h" #include "pinyin_base.h" #include "pinyin_large_table.h" -#include "phrase_index.h" using namespace pinyin; @@ -15,8 +14,6 @@ int main( int argc, char * argv[]){ PinyinCustomSettings custom; PinyinLargeTable largetable(&custom); - FacadePhraseIndex phrase_index; - FILE * gbfile = fopen("../../data/gb_char.table", "r"); if ( gbfile == NULL ) { fprintf(stderr, "open gb_char.table failed!\n"); @@ -24,8 +21,6 @@ int main( int argc, char * argv[]){ } largetable.load_text(gbfile); - fseek(gbfile, 0L, SEEK_SET); - phrase_index.load_text(1, gbfile); fclose(gbfile); FILE * gbkfile = fopen("../../data/gbk_char.table","r"); @@ -35,8 +30,6 @@ int main( int argc, char * argv[]){ } largetable.load_text(gbkfile); - fseek(gbkfile, 0L, SEEK_SET); - phrase_index.load_text(2, gbkfile); fclose(gbkfile); MemoryChunk* new_chunk = new MemoryChunk; @@ -79,34 +72,13 @@ int main( int argc, char * argv[]){ for( size_t i = 0 ; i < PHRASE_INDEX_LIBRARY_COUNT ; ++i){ GArray * range = ranges[i]; if ( range ){ + 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); - gunichar2 bufstr[1024]; - item.get_phrase_string(bufstr); - char * string = g_utf16_to_utf8 - ( bufstr, item.get_phrase_length(), - NULL, NULL, NULL); - printf("%s\t", string); - g_free(string); - PinyinKey pinyin_buffer[1024]; - size_t npron = item.get_n_pronunciation(); - guint32 freq; - for ( size_t n = 0; n < npron; ++n){ - item.get_nth_pronunciation(n, pinyin_buffer, freq); - for ( size_t o = 0; o < item.get_phrase_length(); ++o){ - printf("%s'", pinyin_buffer[o].get_key_string()); - } - printf("\b\t%d\t", freq); - } - printf("\n"); - } + printf("start:%d\tend:%d\n", onerange->m_range_begin, onerange->m_range_end); } - if ( range->len) - printf("range items number:%d\n", range->len); } g_array_set_size( range, 0); } |