From dc3793a21d63b2d919a3a2642dbaf4a5984550c7 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Sat, 8 Sep 2012 11:39:07 +0800 Subject: add dump methods --- src/lookup/pinyin_lookup2.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/lookup/pinyin_lookup2.cpp b/src/lookup/pinyin_lookup2.cpp index 9d5a972..6fef5b6 100644 --- a/src/lookup/pinyin_lookup2.cpp +++ b/src/lookup/pinyin_lookup2.cpp @@ -27,6 +27,42 @@ using namespace pinyin; /* internal definition */ static const size_t nbeam = 32; +static bool dump_max_value(GPtrArray * values){ + if (0 == values->len) + return false; + + const lookup_value_t * max = + (const lookup_value_t *) g_ptr_array_index(values, 0); + + for (size_t i = 1; i < values->len; ++i) { + const lookup_value_t * cur = + (const lookup_value_t *) g_ptr_array_index(values, i); + + if (cur->m_poss > max->m_poss) + max = cur; + } + + printf("max value: %f\n", max->m_poss); + + return true; +} + +static bool dump_all_values(GPtrArray * values) { + if (0 == values->len) + return false; + + printf("values:"); + for (size_t i = 0; i < values->len; ++i) { + const lookup_value_t * cur = + (const lookup_value_t *) g_ptr_array_index(values, i); + + printf("%f\t", cur->m_poss); + } + printf("\n"); + + return true; +} + /* populate the candidates. */ static bool populate_candidates(/* out */ GPtrArray * candidates, /* in */ LookupStepContent step) { @@ -42,6 +78,8 @@ static bool populate_candidates(/* out */ GPtrArray * candidates, g_ptr_array_add(candidates, value); } + dump_max_value(candidates); + return true; } @@ -75,6 +113,8 @@ static bool get_top_results(/* out */ GPtrArray * topresults, break; } + dump_all_values(topresults); + return true; } -- cgit