summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-12-09 14:18:46 +0800
committerPeng Wu <alexepico@gmail.com>2011-12-09 14:18:46 +0800
commit83faf2027fffe8cba367edd9b33905cba1ceb900 (patch)
treefb509aa506d629a588c519246c7c594646f43b60
parent8061ac47263cb9649e457ba7d553f622117fe7dd (diff)
downloadlibpinyin-83faf2027fffe8cba367edd9b33905cba1ceb900.tar.gz
libpinyin-83faf2027fffe8cba367edd9b33905cba1ceb900.tar.xz
libpinyin-83faf2027fffe8cba367edd9b33905cba1ceb900.zip
port chewing table
-rw-r--r--tests/storage/test_chewing_table.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/storage/test_chewing_table.cpp b/tests/storage/test_chewing_table.cpp
index d988222..ef99704 100644
--- a/tests/storage/test_chewing_table.cpp
+++ b/tests/storage/test_chewing_table.cpp
@@ -99,14 +99,32 @@ int main(int argc, char * argv[]) {
for (size_t i = min_index; i < max_index; ++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);
+
+ /* get phrase string */
+ gunichar2 buffer[MAX_PHRASE_LENGTH + 1];
+ item.get_phrase_string(buffer);
+ char * string = g_utf16_to_utf8
+ ( buffer, item.get_phrase_length(),
+ NULL, NULL, NULL);
+ printf("%s\t", string);
+ g_free(string);
+ }
+ printf("\n");
}
- if (range->len)
- printf("range items number:%d\n", range->len);
}
g_array_set_size(range, 0);
}