From c91834aa9ad131f6d67e1f7442cca0029fc4d3cf Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 24 Feb 2016 14:36:46 +0800 Subject: write compute*chewing_index functions --- src/storage/pinyin_phrase3.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/storage/pinyin_phrase3.h b/src/storage/pinyin_phrase3.h index 7e190e2..fa7afdc 100644 --- a/src/storage/pinyin_phrase3.h +++ b/src/storage/pinyin_phrase3.h @@ -24,6 +24,7 @@ #include "novel_types.h" #include "chewing_key.h" +#include namespace pinyin{ @@ -139,8 +140,8 @@ inline int pinyin_compare_with_tones(const ChewingKey * key_lhs, return 0; } -inline bool contains_incomplete_pinyin(int phrase_length, - const ChewingKey * keys) { +inline bool contains_incomplete_pinyin(const ChewingKey * keys, + int phrase_length) { for (int i = 0; i < phrase_length; ++i) { const ChewingKey key = keys[i]; if (CHEWING_ZERO_MIDDLE == key.m_middle && @@ -153,6 +154,26 @@ inline bool contains_incomplete_pinyin(int phrase_length, return false; } +inline void compute_chewing_index(const ChewingKey * in_keys, + ChewingKey * out_keys, + int phrase_length) { + for (int i = 0; i < phrase_length; ++i) { + ChewingKey key = in_keys[i]; + key.m_tone = CHEWING_ZERO_TONE; + out_keys[i] = key; + } +} + +inline void compute_incomplete_chewing_index(const ChewingKey * in_keys, + ChewingKey * out_keys, + int phrase_length) { + for (int i = 0; i < phrase_length; ++i) { + ChewingKey key; + key.m_initial = in_keys[i].m_initial; + out_keys[i] = key; + } +} + template struct PinyinIndexItem2{ phrase_token_t m_token; -- cgit