From c0ff923d2fc2a5e02d76decb95d3a8f4dd14c63c Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 27 Oct 2011 10:38:40 +0800 Subject: update chewing_key.h --- .gitignore | 1 + src/storage/chewing_key.h | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/.gitignore b/.gitignore index 390aefa..0b34dec 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ libltdl *~ *.o *.lo +*.pyc .deps .libs tags diff --git a/src/storage/chewing_key.h b/src/storage/chewing_key.h index f42c66c..970ed72 100644 --- a/src/storage/chewing_key.h +++ b/src/storage/chewing_key.h @@ -118,12 +118,39 @@ enum ChewingTone CHEWING_NUMBER_OF_TONES = CHEWING_LAST_TONE + 1 }; + +/** Note: The parsed pinyins are stored in the following two + * GArrays to speed up chewing table lookup. + * As the chewing table only contains information of struct ChewingKey. + */ + struct ChewingKey { guint16 m_initial : 5; guint16 m_middle : 2; guint16 m_final : 5; guint16 m_tone : 3; + + ChewingKey() { + m_initial = CHEWING_ZERO_INITIAL; + m_middle = CHEWING_ZERO_MIDDLE; + m_final = CHEWING_ZERO_FINAL; + m_tone = CHEWING_ZERO_TONE; + } +}; + +struct ChewingKeyRest +{ + guint16 m_index; /* the index in pinyin parser table. */ + guint16 m_pinyin_begin; /* the begin of pinyin in raw input. */ + guint16 m_pinyin_end; /* the end of pinyin in raw input. */ + + ChewingKeyRest() { + /* the 0th item in pinyin parser table is reserved for invalid. */ + m_index = 0; + m_pinyin_begin = 0; + m_pinyin_end = 0; + } }; }; -- cgit