diff options
author | Peng Wu <alexepico@gmail.com> | 2016-02-24 14:36:46 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2016-02-24 14:36:46 +0800 |
commit | c91834aa9ad131f6d67e1f7442cca0029fc4d3cf (patch) | |
tree | 38afe829382d10abb992f8bb913d3ec1ada963be /src/storage/pinyin_phrase3.h | |
parent | f142f1c24866423974a692c3e71b6e052faf5e61 (diff) | |
download | libpinyin-c91834aa9ad131f6d67e1f7442cca0029fc4d3cf.tar.gz libpinyin-c91834aa9ad131f6d67e1f7442cca0029fc4d3cf.tar.xz libpinyin-c91834aa9ad131f6d67e1f7442cca0029fc4d3cf.zip |
write compute*chewing_index functions
Diffstat (limited to 'src/storage/pinyin_phrase3.h')
-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; |