libUnihan 0.5.3
|
00001 00016 /* 00017 * Copyright © 2008 Red Hat, Inc. All rights reserved. 00018 * Copyright © 2008 Ding-Yi Chen <dchen at redhat dot com> 00019 * 00020 * This file is part of the libUnihan Project. 00021 * 00022 * This library is free software; you can redistribute it and/or 00023 * modify it under the terms of the GNU Lesser General Public 00024 * License as published by the Free Software Foundation; either 00025 * version 2 of the License, or (at your option) any later version. 00026 * 00027 * This library is distributed in the hope that it will be useful, 00028 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00029 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00030 * GNU Lesser General Public License for more details. 00031 * 00032 * You should have received a copy of the GNU Lesser General Public 00033 * License along with this program; if not, write to the 00034 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 00035 * Boston, MA 02111-1307 USA 00036 */ 00037 00038 #ifndef UNIHAN_PHONETIC_H_ 00039 #define UNIHAN_PHONETIC_H_ 00040 00041 #include <sqlite3.h> 00042 00046 #define PINYIN_MAX_LENGTH 9 00047 00051 #define ZHUYIN_MAX_LENGTH 13 00052 00056 typedef gunichar ZhuYin_Symbol; 00057 00061 typedef char ZhuYin; 00062 00066 typedef char PinYin; 00067 00068 00069 00082 typedef enum { 00083 ZHUYIN_INVALID_SYMBOL= -1, 00084 ZHUYIN_SYMBOL_B, 00085 ZHUYIN_SYMBOL_P, 00086 ZHUYIN_SYMBOL_M, 00087 ZHUYIN_SYMBOL_F, 00088 ZHUYIN_SYMBOL_D, 00089 ZHUYIN_SYMBOL_T, 00090 ZHUYIN_SYMBOL_N, 00091 ZHUYIN_SYMBOL_L, 00092 ZHUYIN_SYMBOL_G, 00093 ZHUYIN_SYMBOL_K, 00094 ZHUYIN_SYMBOL_H, 00095 ZHUYIN_SYMBOL_J, 00096 ZHUYIN_SYMBOL_Q, 00097 ZHUYIN_SYMBOL_X, 00098 ZHUYIN_SYMBOL_ZH, 00099 ZHUYIN_SYMBOL_CH, 00100 ZHUYIN_SYMBOL_SH, 00101 ZHUYIN_SYMBOL_R, 00102 ZHUYIN_SYMBOL_Z, 00103 ZHUYIN_SYMBOL_C, 00104 ZHUYIN_SYMBOL_S, 00105 ZHUYIN_SYMBOL_I, 00106 ZHUYIN_SYMBOL_U, 00107 ZHUYIN_SYMBOL_U_DIAERESIS, 00108 ZHUYIN_SYMBOL_A, 00109 ZHUYIN_SYMBOL_O, 00110 ZHUYIN_SYMBOL_E, 00111 ZHUYIN_SYMBOL_E_CIRCUMFLEX, 00112 ZHUYIN_SYMBOL_AI, 00113 ZHUYIN_SYMBOL_EI, 00114 ZHUYIN_SYMBOL_AO, 00115 ZHUYIN_SYMBOL_OU, 00116 ZHUYIN_SYMBOL_AN, 00117 ZHUYIN_SYMBOL_EN, 00118 ZHUYIN_SYMBOL_ANG, 00119 ZHUYIN_SYMBOL_ENG, 00120 ZHUYIN_SYMBOL_ER, 00121 ZHUYIN_SYMBOL_1, 00122 ZHUYIN_SYMBOL_2, 00123 ZHUYIN_SYMBOL_3, 00124 ZHUYIN_SYMBOL_4, 00125 ZHUYIN_SYMBOL_NEUTRAL, 00126 } ZhuYin_Symbol_Id; 00127 00131 #define ZHUYIN_SYMBOL_COUNT ZHUYIN_SYMBOL_NEUTRAL + 1 00132 00136 extern const ZhuYin_Symbol ZHUYIN_SYMBOL_LIST[]; 00137 00166 typedef enum{ 00167 PINYIN_ACCENT_ALWAYS, 00168 PINYIN_ACCENT_ORIGINAL, 00169 PINYIN_ACCENT_UNIHAN, 00170 PINYIN_ACCENT_TRAILING, 00171 PINYIN_ACCENT_INPUT_METHOD, 00172 PINYIN_ACCENT_NONE 00173 } PinYin_Accent_Format; 00174 00175 00192 typedef enum{ 00193 ZHUYIN_TONEMARK_ALWAYS, 00194 ZHUYIN_TONEMARK_ORIGINAL, 00195 ZHUYIN_TONEMARK_INPUT_METHOD, 00196 ZHUYIN_TONEMARK_NUMERICAL, 00197 } ZhuYin_ToneMark_Format; 00198 00199 00200 /*========================================================== 00201 * PinYin functions. 00202 */ 00203 00218 PinYin *pinYin_new(const char *pinYin_str); 00219 00220 00238 guint pinYin_get_tone(const PinYin* pinYin); 00239 00250 guint pinYin_strip_tone(PinYin* pinYin); 00251 00264 void pinYin_add_tone(PinYin* pinYin, guint tone, gboolean useTrailNumber); 00265 00281 PinYin *pinYin_convert_accent_format(const PinYin *pinYin, PinYin_Accent_Format toFormat, gboolean useTrailNumber); 00282 00283 00292 ZhuYin *pinYin_to_zhuYin(const PinYin* pinYin, ZhuYin_ToneMark_Format toFormat); 00293 00294 /*========================================================== 00295 * ZhuYin functions. 00296 */ 00297 00312 ZhuYin *zhuYin_new(const char *zhuYin_str); 00313 00314 00332 guint zhuYin_get_tone(const ZhuYin* zhuYin); 00333 00334 00345 guint zhuYin_strip_tone(ZhuYin* zhuYin); 00346 00359 void zhuYin_add_tone(ZhuYin* zhuYin, guint tone, ZhuYin_ToneMark_Format toFormat); 00360 00375 ZhuYin *zhuYin_convert_toneMark_format(const ZhuYin* zhuYin, ZhuYin_ToneMark_Format toFormat); 00376 00386 PinYin *zhuYin_to_pinYin(const ZhuYin* zhuYin, PinYin_Accent_Format toFormat, gboolean useTrailNumber); 00387 00388 00389 /*---------------------------------------------------------- 00390 * ZhuYin symbol functions. 00391 */ 00392 00400 ZhuYin_Symbol zhuYin_Symbol_from_id(ZhuYin_Symbol_Id id); 00401 00402 00409 ZhuYin_Symbol_Id zhuYin_Symbol_get_id(ZhuYin_Symbol zSym); 00410 00417 gboolean zhuYin_Symbol_is_initial(ZhuYin_Symbol zSym); 00418 00425 gboolean zhuYin_Symbol_is_medial(ZhuYin_Symbol zSym); 00426 00433 gboolean zhuYin_Symbol_is_final(ZhuYin_Symbol zSym); 00434 00441 gboolean zhuYin_Symbol_is_tone(ZhuYin_Symbol zSym); 00442 00449 guint zhuYin_Symbol_to_toneMark_id(ZhuYin_Symbol zSym); 00450 00457 ZhuYin_Symbol zhuYin_Symbol_from_toneMark_id(guint toneMark_id); 00458 00469 void pinYin_convert_accent_format_scalar_func(sqlite3_context *context, int argc, sqlite3_value **argv); 00470 00481 void pinYin_to_zhuYin_scalar_func(sqlite3_context *context, int argc, sqlite3_value **argv); 00482 00493 void zhuYin_convert_toneMark_format_scalar_func(sqlite3_context *context, int argc, sqlite3_value **argv); 00494 00495 00506 void zhuYin_to_pinYin_scalar_func(sqlite3_context *context, int argc, sqlite3_value **argv); 00507 00508 #endif /* UNIHAN_PHONETIC_H_ */