diff options
author | Peng Wu <alexepico@gmail.com> | 2012-09-08 11:39:07 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-09-08 11:39:07 +0800 |
commit | dc3793a21d63b2d919a3a2642dbaf4a5984550c7 (patch) | |
tree | d2c744bc422b11d5b495fbe8532d592ad915d10e /src/lookup | |
parent | ebe2e4da4b641915a33aeb574fd35ee1a155ff4f (diff) | |
download | libpinyin-dc3793a21d63b2d919a3a2642dbaf4a5984550c7.tar.gz libpinyin-dc3793a21d63b2d919a3a2642dbaf4a5984550c7.tar.xz libpinyin-dc3793a21d63b2d919a3a2642dbaf4a5984550c7.zip |
add dump methods
Diffstat (limited to 'src/lookup')
-rw-r--r-- | src/lookup/pinyin_lookup2.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
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; } |