refine candidate api
authorPeng Wu <alexepico@gmail.com>
Tue, 17 Apr 2012 04:37:41 +0000 (12:37 +0800)
committerPeng Wu <alexepico@gmail.com>
Tue, 17 Apr 2012 04:37:41 +0000 (12:37 +0800)
src/pinyin.cpp
src/pinyin.h

index b4965400130b4943b4cc0847ade781c98100fd99..2b205891e65ab728e638bc599de728f4aaf6e526 100644 (file)
@@ -617,9 +617,14 @@ bool pinyin_get_candidates(pinyin_instance_t * instance,
 #endif
 
 /* internal definition */
-typedef struct {
+typedef struct _compare_item_t{
     phrase_token_t m_token;
     guint32 m_freq; /* the amplifed gfloat numerical value. */
+
+public:
+    _compare_item_t(){
+        m_token = null_token; m_freq = 0;
+    }
 } compare_item_t;
 
 static gint compare_item_with_token(gconstpointer lhs,
@@ -730,7 +735,7 @@ bool pinyin_get_candidates(pinyin_instance_t * instance,
                 for (size_t k = range->m_range_begin;
                      k < range->m_range_end; ++k) {
                     compare_item_t item;
-                    item.m_token = k; item.m_freq = 0;
+                    item.m_token = k;
                     g_array_append_val(items, item);
                 }
             }
index e8b751ab4c1647cf7336e3d460e46cbb9ec5982f..d4f14ce39320e2ebf309b3d75999bd8b56dea24b 100644 (file)
@@ -50,6 +50,14 @@ struct _lookup_candidate_t{
     phrase_token_t m_token;
     ChewingKeyRest m_orig_rest;
     gchar * m_new_pinyins;
+    guint32 m_freq; /* the amplifed gfloat numerical value. */
+public:
+    _lookup_candidate_t() {
+        m_candidate_type = NORMAL_CANDIDATE;
+        m_token = null_token;
+        m_new_pinyins = NULL;
+        m_freq = 0;
+    }
 };
 
 struct _pinyin_instance_t{
@@ -301,9 +309,9 @@ bool pinyin_get_candidates(pinyin_instance_t * instance,
                            size_t offset,
                            TokenVector candidates);
 
-bool pinyin_get_candidates_v2(pinyin_instance_t * instance,
-                              size_t offset,
-                              CandidateVector candidates);
+bool pinyin_get_full_pinyin_candidates(pinyin_instance_t * instance,
+                                       size_t offset,
+                                       CandidateVector candidates);
 
 /**
  * pinyin_choose_candidate:
@@ -319,9 +327,9 @@ int pinyin_choose_candidate(pinyin_instance_t * instance,
                             size_t offset,
                             phrase_token_t token);
 
-int pinyin_choose_candidate_v2(pinyin_instance_t * instance,
-                               size_t offset,
-                               lookup_candidate_t * candidate);
+int pinyin_choose_full_pinyin_candidate(pinyin_instance_t * instance,
+                                        size_t offset,
+                                        lookup_candidate_t * candidate);
 
 /**
  * pinyin_clear_constraint: