summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-09-12 15:24:44 +0800
committerPeng Wu <alexepico@gmail.com>2013-09-12 15:24:44 +0800
commit22d3719a8a2fc1343af1de100b6bb92a1b171b7e (patch)
treee11760655858fd69ca98ffe9e983d85218ae7b23
parent74a8337065edeea7308269338ec537fb6b5acd05 (diff)
downloadlibzhuyin-22d3719a8a2fc1343af1de100b6bb92a1b171b7e.tar.gz
libzhuyin-22d3719a8a2fc1343af1de100b6bb92a1b171b7e.tar.xz
libzhuyin-22d3719a8a2fc1343af1de100b6bb92a1b171b7e.zip
begin to write ChewingDiscreteParser2
-rw-r--r--src/storage/pinyin_parser2.cpp1
-rw-r--r--src/storage/pinyin_parser2.h41
2 files changed, 42 insertions, 0 deletions
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp
index dc2421e..079af34 100644
--- a/src/storage/pinyin_parser2.cpp
+++ b/src/storage/pinyin_parser2.cpp
@@ -225,6 +225,7 @@ static inline bool search_chewing_index(pinyin_option_t options,
/* Full Pinyin Parser */
FullPinyinParser2::FullPinyinParser2 (){
+ m_pinyin_index = NULL; m_pinyin_index_len = 0;
m_parse_steps = g_array_new(TRUE, FALSE, sizeof(parse_value_t));
set_scheme(PINYIN_DEFAULT);
diff --git a/src/storage/pinyin_parser2.h b/src/storage/pinyin_parser2.h
index 6b530b7..75bc038 100644
--- a/src/storage/pinyin_parser2.h
+++ b/src/storage/pinyin_parser2.h
@@ -186,6 +186,47 @@ public:
};
+/**
+ * ChewingDiscreteParser2:
+ *
+ * Parse the chewing string into an array of struct ChewingKeys.
+ *
+ * Initially will support HSU, HSU Dvorak and ETEN26.
+ *
+ * Plan to replace ChewingSimpleParser2 in future,
+ * as this class is more powerful.
+ */
+
+class ChewingDiscreteParser2 : public PhoneticParser2
+{
+ /* Note: some internal pointers to chewing scheme table. */
+protected:
+ const chewing_index_item_t * m_chewing_index;
+ size_t m_chewing_index_len;
+ const chewing_symbol_item_t * m_initial_table;
+ const chewing_symbol_item_t * m_middle_table;
+ const chewing_symbol_item_t * m_final_table;
+ const chewing_tone_item_t * m_tone_table;
+
+public:
+ ChewingDiscreteParser2() {
+ m_chewing_index = NULL; m_chewing_index_len = 0;
+ m_initial_table = NULL; m_middle_table = NULL;
+ m_final_table = NULL; m_tone_table = NULL;
+ set_scheme(CHEWING_DEFAULT);
+ }
+
+ virtual ~ChewingDiscreteParser2() {}
+
+ virtual bool parse_one_key(pinyin_option_t options, ChewingKey & key, const char *str, int len) const;
+
+ virtual int parse(pinyin_option_t options, ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, const char *str, int len) const;
+
+public:
+ bool set_scheme(ChewingScheme scheme);
+ bool in_chewing_scheme(pinyin_option_t options, const char key, const char ** symbol) const;
+};
+
/* compare pinyins with chewing internal representations. */
inline int pinyin_compare_initial2(pinyin_option_t options,
ChewingInitial lhs,