00001
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef UNIHAN_PHONETIC_H_
00041 #define UNIHAN_PHONETIC_H_
00042
00043 #include <sqlite3.h>
00044 #include "Unihan_phonetic-private.h"
00045
00049 #define PINYIN_MAX_LENGTH 13
00050
00054 #define ZHUYIN_MAX_LENGTH 13
00055
00059 #define TRANSCRIPTION_MAX_LENGTH 13
00060
00064 typedef gunichar ZhuyinSymbol;
00065
00069 typedef char Zhuyin;
00070
00074 typedef char Pinyin;
00075
00091 typedef struct{
00092 char transcription[TRANSCRIPTION_MAX_LENGTH];
00093 guint tone;
00094 } Syllable;
00095
00109 #define PINYIN_REGEX_IMPORT PINYIN_REGEX_IMPORT_PRIVATE
00110
00111 #define PINYIN_IMPORT_SUBSTITUTE PINYIN_IMPORT_SUBSTITUTE_PRIVATE
00112
00116 #define PINYIN_IMPORT_SUBSTITUTE_TONE_ACCENT PINYIN_IMPORT_SUBSTITUTE_TONE_ACCENT_PRIVATE
00117
00121 #define PINYIN_IMPORT_SUBSTITUTE_TONE PINYIN_IMPORT_SUBSTITUTE_TONE_ACCENT "$20"
00122
00123
00129 #define PINYIN_IMPORT_SUBSTITUTE_XHC PINYIN_IMPORT_SUBSTITUTE_XHC_PRIVATE
00130
00136 #define PINYIN_IMPORT_SUBSTITUTE_TONE_ACCENT_XHC PINYIN_IMPORT_SUBSTITUTE_TONE_ACCENT_XHC_PRIVATE
00137
00143 #define PINYIN_IMPORT_SUBSTITUTE_TONE_XHC PINYIN_IMPORT_SUBSTITUTE_TONE_ACCENT_XHC "$24"
00144
00145
00163 typedef enum {
00164 ZHUYIN_INVALID_SYMBOL= -1,
00165 ZHUYIN_SYMBOL_B,
00166 ZHUYIN_SYMBOL_P,
00167 ZHUYIN_SYMBOL_M,
00168 ZHUYIN_SYMBOL_F,
00169 ZHUYIN_SYMBOL_D,
00170 ZHUYIN_SYMBOL_T,
00171 ZHUYIN_SYMBOL_N,
00172 ZHUYIN_SYMBOL_L,
00173 ZHUYIN_SYMBOL_G,
00174 ZHUYIN_SYMBOL_K,
00175 ZHUYIN_SYMBOL_H,
00176 ZHUYIN_SYMBOL_J,
00177 ZHUYIN_SYMBOL_Q,
00178 ZHUYIN_SYMBOL_X,
00179 ZHUYIN_SYMBOL_ZH,
00180 ZHUYIN_SYMBOL_CH,
00181 ZHUYIN_SYMBOL_SH,
00182 ZHUYIN_SYMBOL_R,
00183 ZHUYIN_SYMBOL_Z,
00184 ZHUYIN_SYMBOL_C,
00185 ZHUYIN_SYMBOL_S,
00186 ZHUYIN_SYMBOL_I,
00187 ZHUYIN_SYMBOL_U,
00188 ZHUYIN_SYMBOL_U_DIAERESIS,
00189 ZHUYIN_SYMBOL_A,
00190 ZHUYIN_SYMBOL_O,
00191 ZHUYIN_SYMBOL_E,
00192 ZHUYIN_SYMBOL_E_CIRCUMFLEX,
00193 ZHUYIN_SYMBOL_AI,
00194 ZHUYIN_SYMBOL_EI,
00195 ZHUYIN_SYMBOL_AO,
00196 ZHUYIN_SYMBOL_OU,
00197 ZHUYIN_SYMBOL_AN,
00198 ZHUYIN_SYMBOL_EN,
00199 ZHUYIN_SYMBOL_ANG,
00200 ZHUYIN_SYMBOL_ENG,
00201 ZHUYIN_SYMBOL_ER,
00202 ZHUYIN_SYMBOL_1,
00203 ZHUYIN_SYMBOL_2,
00204 ZHUYIN_SYMBOL_3,
00205 ZHUYIN_SYMBOL_4,
00206 ZHUYIN_SYMBOL_NEUTRAL,
00207 } ZhuyinSymbolId;
00208
00212 #define ZHUYIN_SYMBOL_COUNT ZHUYIN_SYMBOL_NEUTRAL + 1
00213
00217 extern const ZhuyinSymbol ZHUYIN_SYMBOL_LIST[];
00218
00219
00238 typedef guint PinyinFormatFlags;
00239
00246 #define PINYIN_FORMAT_FLAG_STRIP_TRIVIAL_ACCENT 0x1
00247 #define PINYIN_FORMAT_FLAG_STRIP_CIRCUMFLEX 0x2
00248 #define PINYIN_FORMAT_FLAG_STRIP_DIAERESIS 0x4
00249 #define PINYIN_FORMAT_FLAG_NFD 0x8
00250
00258 #define PINYIN_FORMAT_FLAG_ASCII_ONLY 0x10
00259
00260
00269 #define PINYIN_FORMAT_FLAG_TONE_AS_ACCENT 0x20
00270
00275 #define PINYIN_FORMAT_FLAG_STRIP_TRIVIAL_TONE 0x40
00276
00316 typedef enum{
00317 PINYIN_ACCENT_ALWAYS,
00318 PINYIN_ACCENT_ORIGINAL,
00319 PINYIN_ACCENT_UNIHAN,
00320 PINYIN_ACCENT_TRAILING,
00321 PINYIN_ACCENT_INPUT_METHOD,
00322 PINYIN_ACCENT_NONE,
00323 PINYIN_ACCENT_INTERNAL
00324 } PinyinAccentFormat;
00325
00334 PinyinFormatFlags pinyinAccentFormat_to_pinyinFormatFlags(
00335 PinyinAccentFormat toFormat, gboolean useTrailNumber);
00359 typedef guint ZhuyinFormatFlags;
00360
00364 #define ZHUYIN_FORMAT_FLAG_STRIP_1ST_TONE 0x1
00365
00368 #define ZHUYIN_FORMAT_FLAG_FRONT_5TH_TONE 0x2
00369
00372 #define ZHUYIN_FORMAT_FLAG_NUMERICAL_TONE 0x4
00373
00397 typedef enum{
00398 ZHUYIN_TONEMARK_ALWAYS,
00399 ZHUYIN_TONEMARK_ORIGINAL,
00400 ZHUYIN_TONEMARK_INPUT_METHOD,
00401 ZHUYIN_TONEMARK_NUMERICAL,
00402 } ZhuyinToneMarkFormat;
00403
00412 ZhuyinFormatFlags zhuyinToneMarkFormat_to_zhuyinFormatFlags(
00413 ZhuyinToneMarkFormat toFormat);
00422
00423
00424
00425
00435 Syllable *syllable_new();
00436
00450 Syllable *syllable_new_pinyin(const Pinyin *pinyin_str);
00451
00462 Syllable *syllable_new_zhuyin(const Zhuyin *zhuyin_str);
00463
00464
00471 Syllable *syllable_clone(Syllable *syl);
00472
00484 Pinyin *syllable_to_pinyin(Syllable *syl,PinyinFormatFlags formatFlags);
00485
00497 Zhuyin *syllable_to_zhuyin(Syllable *syl,ZhuyinFormatFlags formatFlags);
00498
00506 gboolean syllable_is_zhuyin(Syllable *syl);
00507
00515 gboolean syllable_is_zhuyin_fast(Syllable *syl);
00516
00523 void syllable_free(Syllable *syl);
00524
00533 int syllabel_regex_t_init();
00534
00535
00536
00537
00538
00539
00555 Pinyin *pinyin_new(const char *pinyin_str);
00556
00557
00575 guint pinyin_get_tone(const Pinyin* pinyin);
00576
00591 guint pinyin_strip_tone(Pinyin* pinyin);
00592
00605 guint pinyin_strip_tone_normalized(Pinyin* pinyin);
00606
00619 void pinyin_add_tone(Pinyin* pinyin, guint tone, gboolean useTrailNumber);
00620
00635 void pinyin_add_tone_formatFlags(Pinyin* pinyin, guint tone, PinyinFormatFlags formatFlags);
00636
00637
00657 Pinyin *pinyin_convert_formatFlags(const Pinyin *pinyin, PinyinFormatFlags formatFlags);
00658
00659
00679 Pinyin *pinyin_convert_accent_format(const Pinyin *pinyin, PinyinAccentFormat toFormat, gboolean useTrailNumber);
00680
00681
00682
00692 Zhuyin *pinyin_to_zhuyin(const Pinyin* pinyin, ZhuyinToneMarkFormat toFormat);
00693
00703 Zhuyin *pinyin_to_zhuyin_formatFlags(const Pinyin* pinyin, ZhuyinFormatFlags formatFlags);
00704
00705
00706
00707
00708
00723 Zhuyin *zhuyin_new(const char *zhuyin_str);
00724
00725
00743 guint zhuyin_get_tone(const Zhuyin* zhuyin);
00744
00745
00756 guint zhuyin_strip_tone(Zhuyin* zhuyin);
00757
00769 void zhuyin_add_tone(Zhuyin* zhuyin, guint tone, ZhuyinToneMarkFormat toFormat);
00770
00786 void zhuyin_add_tone_formatFlags(Zhuyin* zhuyin, guint tone, ZhuyinFormatFlags formatFlags);
00787
00803 Zhuyin *zhuyin_convert_toneMark_format(const Zhuyin* zhuyin, ZhuyinToneMarkFormat toFormat);
00804
00822 Zhuyin *zhuyin_convert_formatFlags(const Zhuyin *zhuyin, ZhuyinFormatFlags formatFlags);
00823
00834 Pinyin *zhuyin_to_pinyin(const Zhuyin* zhuyin, PinyinAccentFormat toFormat, gboolean useTrailNumber);
00835
00845 Pinyin *zhuyin_to_pinyin_formatFlags(const Zhuyin* zhuyin, PinyinFormatFlags formatFlags);
00846
00847
00848
00849
00850
00858 ZhuyinSymbol zhuyinSymbol_from_id(ZhuyinSymbolId id);
00859
00860
00867 ZhuyinSymbolId zhuyinSymbol_get_id(ZhuyinSymbol zSym);
00868
00875 gboolean zhuyinSymbol_is_initial(ZhuyinSymbol zSym);
00876
00883 gboolean zhuyinSymbol_is_medial(ZhuyinSymbol zSym);
00884
00891 gboolean zhuyinSymbol_is_final(ZhuyinSymbol zSym);
00892
00899 gboolean zhuyinSymbol_is_tone(ZhuyinSymbol zSym);
00900
00907 guint zhuyinSymbol_to_toneMark_id(ZhuyinSymbol zSym);
00908
00915 ZhuyinSymbol zhuyinSymbol_from_toneMark_id(guint toneMark_id);
00916
00927 void pinyin_convert_accent_format_scalar_func(sqlite3_context *context, int argc, sqlite3_value **argv);
00928
00939 void pinyin_to_zhuyin_scalar_func(sqlite3_context *context, int argc, sqlite3_value **argv);
00940
00951 void zhuyin_convert_toneMark_format_scalar_func(sqlite3_context *context, int argc, sqlite3_value **argv);
00952
00953
00964 void zhuyin_to_pinyin_scalar_func(sqlite3_context *context, int argc, sqlite3_value **argv);
00965
00966 #endif