s2 + w not in pinyin_list and \
s2 + c in pinyin_list:
flag_correct = "PINYIN_CORRECT_%s_TO_%s" % (w.upper(), c.upper())
- yield s1 + w, s2, c, len(s2) + len(w), ["%s | %s" % (flag, flag_correct)]
+ yield s1 + w, s1, c, len(s2) + len(w), ["%s | %s" % (flag, flag_correct)]
# if s2 + y not in pinyin_list and s1 + y in pinyin_list:
# yield s2 + y, s2, y, len (s2) + len(y), [flag]
print '};'
print
- print '#define PINYIN_TABLE_NR (sizeof (pinyin_table) / sizeof (pinyin_table[0]))'
return pinyins
for p in full_pinyin:
print " &pinyin_table[%d], // %s" % (_dict[p], p[0])
print '};'
- print '#define FULL_PINYIN_TABLE_NR (sizeof (full_pinyin_table) / sizeof (full_pinyin_table[0]))'
print
print ' { %s %s %s %s },' % tuple(ids), "/* %s %s => %s %s */" % r
print '};'
- print '#define SPECIAL_TABLE_NR (sizeof (special_table) / sizeof (special_table[0]))'
print
if (G_LIKELY (len > 0)) {
strncpy (buf, p, len);
buf[len] = 0;
- result = (const Pinyin *) bsearch (buf, pinyin_table, PINYIN_TABLE_NR,
+ result = (const Pinyin *) bsearch (buf, pinyin_table, G_N_ELEMENTS (pinyin_table),
sizeof (Pinyin), py_cmp);
if (check_flags (result, option))
return result;
for (; len > 0; len --) {
buf[len] = 0;
- result = (const Pinyin *) bsearch (buf, pinyin_table, PINYIN_TABLE_NR,
+ result = (const Pinyin *) bsearch (buf, pinyin_table, G_N_ELEMENTS (pinyin_table),
sizeof (Pinyin), py_cmp);
if (G_UNLIKELY (check_flags (result, option))) {
return result;
{
const Pinyin * pys[] = {p1, p2};
- return (const Pinyin **) bsearch (pys, special_table, SPECIAL_TABLE_NR,
+ return (const Pinyin **) bsearch (pys, special_table, G_N_ELEMENTS (special_table),
sizeof (special_table[0]), sp_cmp);
}
g_strlcpy (buf, id_map[sheng], sizeof (buf));
g_strlcat (buf, id_map[yun], sizeof (buf));
- result = (const Pinyin *) bsearch (buf, pinyin_table, PINYIN_TABLE_NR,
+ result = (const Pinyin *) bsearch (buf, pinyin_table, G_N_ELEMENTS (pinyin_table),
sizeof (Pinyin), py_cmp);
if (check_flags (result, option))
return result;
},
{ /* 151 */
text : "fuei",
- sheng : "h",
+ sheng : "f",
yun : "ui",
- sheng_id : PINYIN_ID_H,
+ sheng_id : PINYIN_ID_F,
yun_id : PINYIN_ID_UI,
- fsheng_id : PINYIN_ID_F,
+ fsheng_id : PINYIN_ID_H,
fyun_id : PINYIN_ID_ZERO,
fsheng_id_2 : PINYIN_ID_ZERO,
fyun_id_2 : PINYIN_ID_ZERO,
},
{ /* 152 */
text : "fuen",
- sheng : "h",
+ sheng : "f",
yun : "un",
- sheng_id : PINYIN_ID_H,
+ sheng_id : PINYIN_ID_F,
yun_id : PINYIN_ID_UN,
- fsheng_id : PINYIN_ID_F,
+ fsheng_id : PINYIN_ID_H,
fyun_id : PINYIN_ID_ZERO,
fsheng_id_2 : PINYIN_ID_ZERO,
fyun_id_2 : PINYIN_ID_ZERO,
},
{ /* 309 */
text : "luei",
- sheng : "r",
+ sheng : "l",
yun : "ui",
- sheng_id : PINYIN_ID_R,
+ sheng_id : PINYIN_ID_L,
yun_id : PINYIN_ID_UI,
- fsheng_id : PINYIN_ID_L,
+ fsheng_id : PINYIN_ID_N,
fyun_id : PINYIN_ID_ZERO,
- fsheng_id_2 : PINYIN_ID_ZERO,
+ fsheng_id_2 : PINYIN_ID_R,
fyun_id_2 : PINYIN_ID_ZERO,
len : 4,
flags : PINYIN_FUZZY_L_R | PINYIN_CORRECT_UEI_TO_UI
},
{ /* 381 */
text : "nuen",
- sheng : "l",
+ sheng : "n",
yun : "un",
- sheng_id : PINYIN_ID_L,
+ sheng_id : PINYIN_ID_N,
yun_id : PINYIN_ID_UN,
- fsheng_id : PINYIN_ID_N,
+ fsheng_id : PINYIN_ID_L,
fyun_id : PINYIN_ID_ZERO,
- fsheng_id_2 : PINYIN_ID_R,
+ fsheng_id_2 : PINYIN_ID_ZERO,
fyun_id_2 : PINYIN_ID_ZERO,
len : 4,
flags : PINYIN_FUZZY_N_L | PINYIN_CORRECT_UEN_TO_UN
},
{ /* 460 */
text : "riou",
- sheng : "l",
+ sheng : "r",
yun : "iu",
- sheng_id : PINYIN_ID_L,
+ sheng_id : PINYIN_ID_R,
yun_id : PINYIN_ID_IU,
- fsheng_id : PINYIN_ID_N,
+ fsheng_id : PINYIN_ID_L,
fyun_id : PINYIN_ID_ZERO,
- fsheng_id_2 : PINYIN_ID_R,
+ fsheng_id_2 : PINYIN_ID_ZERO,
fyun_id_2 : PINYIN_ID_ZERO,
len : 4,
flags : PINYIN_FUZZY_R_L | PINYIN_CORRECT_IOU_TO_IU
},
{ /* 470 */
text : "rue",
- sheng : "l",
+ sheng : "r",
yun : "ve",
- sheng_id : PINYIN_ID_L,
+ sheng_id : PINYIN_ID_R,
yun_id : PINYIN_ID_VE,
- fsheng_id : PINYIN_ID_N,
+ fsheng_id : PINYIN_ID_L,
fyun_id : PINYIN_ID_ZERO,
- fsheng_id_2 : PINYIN_ID_R,
+ fsheng_id_2 : PINYIN_ID_ZERO,
fyun_id_2 : PINYIN_ID_ZERO,
len : 3,
flags : PINYIN_FUZZY_R_L | PINYIN_CORRECT_UE_TO_VE
},
};
-#define PINYIN_TABLE_NR (sizeof (pinyin_table) / sizeof (pinyin_table[0]))
static const Pinyin *special_table[][4] = {
{ &pinyin_table[4], &pinyin_table[0], &pinyin_table[0], &pinyin_table[345], }, /* an a => a na */
{ &pinyin_table[4], &pinyin_table[6], &pinyin_table[0], &pinyin_table[351], }, /* an ao => a nao */
{ &pinyin_table[692], &pinyin_table[126], &pinyin_table[684], &pinyin_table[354], }, /* zun ei => zu nei */
{ &pinyin_table[692], &pinyin_table[127], &pinyin_table[684], &pinyin_table[356], }, /* zun en => zu nen */
};
-#define SPECIAL_TABLE_NR (sizeof (special_table) / sizeof (special_table[0]))