3 * Library to deal with pinyin.
5 * Copyright (C) 2011 Peng Wu <alexepico@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 /** @file chewing_key.h
28 * @brief the definitions of chewing key related classes and structs.
33 * @brief enums of chewing initial element.
37 CHEWING_ZERO_INITIAL = 0, /* zero initial. */
38 CHEWING_B = 1, /* "ㄅ". */
39 CHEWING_C = 2, /* "ㄘ". */
40 CHEWING_CH = 3, /* "ㄔ". */
41 CHEWING_D = 4, /* "ㄉ". */
42 CHEWING_F = 5, /* "ㄈ". */
43 CHEWING_H = 6, /* "ㄏ". */
44 CHEWING_G = 7, /* "ㄍ". */
45 CHEWING_K = 8, /* "ㄎ". */
46 CHEWING_J = 9, /* "ㄐ". */
47 CHEWING_M = 10, /* "ㄇ". */
48 CHEWING_N = 11, /* "ㄋ". */
49 CHEWING_L = 12, /* "ㄌ". */
50 CHEWING_R = 13, /* "ㄖ". */
51 CHEWING_P = 14, /* "ㄆ". */
52 CHEWING_Q = 15, /* "ㄑ". */
53 CHEWING_S = 16, /* "ㄙ". */
54 CHEWING_SH = 17, /* "ㄕ". */
55 CHEWING_T = 18, /* "ㄊ". */
56 PINYIN_W = 19, /* Invalid Chewing. */
57 CHEWING_X = 20, /* "ㄒ". */
58 PINYIN_Y = 21, /* Invalid Chewing. */
59 CHEWING_Z = 22, /* "ㄗ". */
60 CHEWING_ZH = 23, /* "ㄓ". */
61 CHEWING_LAST_INITIAL = CHEWING_ZH,
62 CHEWING_NUMBER_OF_INITIALS = CHEWING_LAST_INITIAL + 1
67 * @brief enums of chewing middle element.
72 CHEWING_ZERO_MIDDLE = 0, /* zero middle. */
73 CHEWING_I = 1, /* "ㄧ". */
74 CHEWING_U = 2, /* "ㄨ". */
75 CHEWING_V = 3, /* "ㄩ". */
76 CHEWING_LAST_MIDDLE = CHEWING_V,
77 CHEWING_NUMBER_OF_MIDDLES = CHEWING_LAST_MIDDLE + 1
81 * @brief enums of chewing final element.
85 CHEWING_ZERO_FINAL = 0, /* zero final */
86 CHEWING_A = 1, /* "ㄚ". */
87 CHEWING_AI = 2, /* "ㄞ". */
88 CHEWING_AN = 3, /* "ㄢ". */
89 CHEWING_ANG = 4, /* "ㄤ". */
90 CHEWING_AO = 5, /* "ㄠ". */
91 CHEWING_E = 6, /* "ㄝ" and "ㄜ". */
92 INVALID_EA = 7, /* Invalid Pinyin/Chewing. */
93 CHEWING_EI = 8, /* "ㄟ". */
94 CHEWING_EN = 9, /* "ㄣ". */
95 CHEWING_ENG = 10, /* "ㄥ". */
96 CHEWING_ER = 11, /* "ㄦ". */
97 CHEWING_NG = 12, /* "ㄫ". */
98 CHEWING_O = 13, /* "ㄛ". */
99 PINYIN_ONG = 14, /* "ueng". */
100 CHEWING_OU = 15, /* "ㄡ". */
101 PINYIN_IN = 16, /* "ien". */
102 PINYIN_ING = 17, /* "ieng". */
103 CHEWING_LAST_FINAL = PINYIN_ING,
104 CHEWING_NUMBER_OF_FINALS = CHEWING_LAST_FINAL + 1
109 * @brief enums of chewing tone element.
113 CHEWING_ZERO_TONE = 0, /* zero tone. */
119 CHEWING_LAST_TONE = CHEWING_5,
120 CHEWING_NUMBER_OF_TONES = CHEWING_LAST_TONE + 1
124 * @brief enums of Double Pinyin Schemes.
126 enum DoublePinyinScheme
128 DOUBLE_PINYIN_ZRM = 1,
129 DOUBLE_PINYIN_MS = 2,
130 DOUBLE_PINYIN_ZIGUANG = 3,
131 DOUBLE_PINYIN_ABC = 4,
132 DOUBLE_PINYIN_PYJJ = 6,
133 DOUBLE_PINYIN_XHE = 7,
134 DOUBLE_PINYIN_CUSTOMIZED = 30, /* for user's keyboard */
135 DOUBLE_PINYIN_DEFAULT = DOUBLE_PINYIN_MS
139 * @brief enums of Chewing Schemes.
143 CHEWING_STANDARD = 1,
146 CHEWING_GIN_YIEH = 4,
149 CHEWING_DEFAULT = CHEWING_STANDARD
153 /** Note: The parsed pinyins are stored in the following two
154 * GArrays to speed up chewing table lookup.
155 * As the chewing large table only contains information of struct ChewingKey.
160 guint16 m_initial : 5;
161 guint16 m_middle : 2;
166 m_initial = CHEWING_ZERO_INITIAL;
167 m_middle = CHEWING_ZERO_MIDDLE;
168 m_final = CHEWING_ZERO_FINAL;
169 m_tone = CHEWING_ZERO_TONE;
172 ChewingKey(ChewingInitial initial, ChewingMiddle middle,
173 ChewingFinal final) {
177 m_tone = CHEWING_ZERO_TONE;
181 struct ChewingKeyRest
183 guint16 m_table_index; /* the index in pinyin parser table. */
184 guint16 m_raw_begin; /* the begin of the raw input. */
185 guint16 m_raw_end; /* the end of the raw input. */
188 /* the 0th item in pinyin parser table is reserved for invalid. */
194 const char * get_pinyin_string();
195 const char * get_chewing_string();