summaryrefslogtreecommitdiffstats
path: root/src/lookup
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2017-02-08 12:42:22 +0800
committerPeng Wu <alexepico@gmail.com>2017-02-08 12:42:22 +0800
commit44e570de46e39b5e1ccc4133414cf8ae19e1868b (patch)
tree13c709484726404de1b5a5e9c74ea35f7c6201ab /src/lookup
parentdc963b598e14eec42e4fd22223f287253d424c47 (diff)
downloadlibpinyin-44e570de46e39b5e1ccc4133414cf8ae19e1868b.tar.gz
libpinyin-44e570de46e39b5e1ccc4133414cf8ae19e1868b.tar.xz
libpinyin-44e570de46e39b5e1ccc4133414cf8ae19e1868b.zip
rename variables
Diffstat (limited to 'src/lookup')
-rw-r--r--src/lookup/phonetic_lookup.h18
-rw-r--r--src/lookup/phonetic_lookup_heap.h9
2 files changed, 14 insertions, 13 deletions
diff --git a/src/lookup/phonetic_lookup.h b/src/lookup/phonetic_lookup.h
index f7d49af..c90c994 100644
--- a/src/lookup/phonetic_lookup.h
+++ b/src/lookup/phonetic_lookup.h
@@ -62,28 +62,28 @@ struct trellis_value_t {
};
template <gint32 nbest>
-static bool inline trellis_value_less_than(const trellis_value_t * exist_item,
- const trellis_value_t * new_item) {
+static bool inline trellis_value_less_than(const trellis_value_t * item_lhs,
+ const trellis_value_t * item_rhs) {
#if 1
if (nbest > 1) {
/* allow longer sentence */
- if (exist_item->m_sentence_length + 1 == new_item->m_sentence_length &&
- exist_item->m_poss + LONG_SENTENCE_PENALTY < new_item->m_poss)
+ if (item_lhs->m_sentence_length + 1 == item_rhs->m_sentence_length &&
+ item_lhs->m_poss + LONG_SENTENCE_PENALTY < item_rhs->m_poss)
return true;
- if (exist_item->m_sentence_length == new_item->m_sentence_length + 1 &&
- exist_item->m_poss < new_item->m_poss + LONG_SENTENCE_PENALTY)
+ if (item_lhs->m_sentence_length == item_rhs->m_sentence_length + 1 &&
+ item_lhs->m_poss < item_rhs->m_poss + LONG_SENTENCE_PENALTY)
return true;
}
#endif
/* the same length but better possibility */
- if (exist_item->m_sentence_length == new_item->m_sentence_length &&
- exist_item->m_poss < new_item->m_poss)
+ if (item_lhs->m_sentence_length == item_rhs->m_sentence_length &&
+ item_lhs->m_poss < item_rhs->m_poss)
return true;
/* shorter sentence */
- if (exist_item->m_sentence_length > new_item->m_sentence_length)
+ if (item_lhs->m_sentence_length > item_rhs->m_sentence_length)
return true;
return false;
diff --git a/src/lookup/phonetic_lookup_heap.h b/src/lookup/phonetic_lookup_heap.h
index be1bcea..73eac28 100644
--- a/src/lookup/phonetic_lookup_heap.h
+++ b/src/lookup/phonetic_lookup_heap.h
@@ -22,10 +22,10 @@
#define PHONETIC_LOOKUP_HEAP_H
template <gint32 nbest>
-static inline bool trellis_value_comp(const trellis_value_t &exist_item,
- const trellis_value_t &new_item) {
+static inline bool trellis_value_comp(const trellis_value_t &lhs,
+ const trellis_value_t &rhs) {
/* min heap here */
- return trellis_value_less_than<nbest>(&exist_item, &new_item);
+ return trellis_value_less_than<nbest>(&lhs, &rhs);
}
template <gint32 nbest>
@@ -55,12 +55,13 @@ public:
/* return true if the item is stored into m_elements. */
bool eval_item(const trellis_value_t * item) {
- /* min heap here, and always push heap. */
+ /* min heap here. */
/* still have space */
if (m_nelem < nbest) {
m_elements[m_nelem] = *item;
m_nelem ++;
+ /* always push heap. */
std_lite::push_heap(m_elements, m_elements + m_nelem, trellis_value_comp<nbest>);
return true;
}