diff options
-rw-r--r-- | src/storage/pinyin_phrase3.h | 25 |
1 files 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 <assert.h> 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<size_t phrase_length> struct PinyinIndexItem2{ phrase_token_t m_token; |