diff options
author | Peng Wu <alexepico@gmail.com> | 2011-11-16 10:05:32 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2011-11-16 10:05:32 +0800 |
commit | 4794f487807d6f9ab26df198e27edb46e8353b31 (patch) | |
tree | 176fd6d295ff93d1fcb061e295e559aa66f893a0 /src/storage | |
parent | 3d258a59568cb9d6114b8f80784d94abcb1b7905 (diff) | |
download | libpinyin-4794f487807d6f9ab26df198e27edb46e8353b31.tar.gz libpinyin-4794f487807d6f9ab26df198e27edb46e8353b31.tar.xz libpinyin-4794f487807d6f9ab26df198e27edb46e8353b31.zip |
add use tone option check
Diffstat (limited to 'src/storage')
-rw-r--r-- | src/storage/pinyin_parser2.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index 4e3cbc2..6ace7ce 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -104,12 +104,14 @@ int FullPinyinParser2::parse_one_key (guint32 options, ChewingKey & key, guint16 parsed_len = len; key = ChewingKey(); key_rest = ChewingKeyRest(); - /* find the tone in the last character. */ - char chr = input[parsed_len - 1]; - if ( '0' < chr && chr <= '5' ) { - tone = chr - '0'; - parsed_len --; - tone_pos = parsed_len; + if (options & USE_TONE) { + /* find the tone in the last character. */ + char chr = input[parsed_len - 1]; + if ( '0' < chr && chr <= '5' ) { + tone = chr - '0'; + parsed_len --; + tone_pos = parsed_len; + } } /* parse pinyin core staff here. */ @@ -139,11 +141,13 @@ int FullPinyinParser2::parse_one_key (guint32 options, ChewingKey & key, } } - /* post processing tone. */ - if ( parsed_len == tone_pos ) { - if (tone != CHEWING_ZERO_TONE) { - key.m_tone = tone; - parsed_len ++; + if (options & USE_TONE) { + /* post processing tone. */ + if ( parsed_len == tone_pos ) { + if (tone != CHEWING_ZERO_TONE) { + key.m_tone = tone; + parsed_len ++; + } } } |