summaryrefslogtreecommitdiffstats
path: root/src/storage
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-11-17 13:45:44 +0800
committerPeng Wu <alexepico@gmail.com>2011-11-17 13:46:52 +0800
commit8ec1d25f1e9cf032897e877b084220f0db60d452 (patch)
tree2038110873043783f486bc63ee594f3b3c1a39bb /src/storage
parent7dbb2263c0ba8690074e663ccebacffc7d1f9dca (diff)
downloadlibpinyin-8ec1d25f1e9cf032897e877b084220f0db60d452.tar.gz
libpinyin-8ec1d25f1e9cf032897e877b084220f0db60d452.tar.xz
libpinyin-8ec1d25f1e9cf032897e877b084220f0db60d452.zip
write pinyin_compare_initial2
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/pinyin_custom2.h12
-rw-r--r--src/storage/pinyin_parser2.h69
2 files changed, 75 insertions, 6 deletions
diff --git a/src/storage/pinyin_custom2.h b/src/storage/pinyin_custom2.h
index d0238cf..0d6cb06 100644
--- a/src/storage/pinyin_custom2.h
+++ b/src/storage/pinyin_custom2.h
@@ -42,12 +42,12 @@ enum PinyinTableFlag{
*/
enum PinyinAmbiguity2{
PINYIN_AMB_C_CH = 1U << 9,
- PINYIN_AMB_Z_ZH = 1U << 10,
- PINYIN_AMB_S_SH = 1U << 11,
- PINYIN_AMB_L_N = 1U << 12,
- PINYIN_AMB_F_H = 1U << 13,
- PINYIN_AMB_L_R = 1U << 14,
- PINYIN_AMB_K_G = 1U << 15,
+ PINYIN_AMB_S_SH = 1U << 10,
+ PINYIN_AMB_Z_ZH = 1U << 11,
+ PINYIN_AMB_F_H = 1U << 12,
+ PINYIN_AMB_G_K = 1U << 13,
+ PINYIN_AMB_L_N = 1U << 14,
+ PINYIN_AMB_L_R = 1U << 15,
PINYIN_AMB_AN_ANG = 1U << 16,
PINYIN_AMB_EN_ENG = 1U << 17,
PINYIN_AMB_IN_ING = 1U << 18,
diff --git a/src/storage/pinyin_parser2.h b/src/storage/pinyin_parser2.h
index 57eeacf..c074122 100644
--- a/src/storage/pinyin_parser2.h
+++ b/src/storage/pinyin_parser2.h
@@ -185,6 +185,75 @@ public:
};
+/* compare pinyins with chewing internal representations. */
+int pinyin_compare_initial2 (guint32 options,
+ ChewingInitial lhs,
+ ChewingInitial rhs){
+ if (lhs == rhs)
+ return 0;
+
+ if ((options & PINYIN_AMB_C_CH) &&
+ ((lhs == CHEWING_C && rhs == CHEWING_CH) ||
+ (lhs == CHEWING_CH && rhs == CHEWING_C)))
+ return 0;
+
+ if ((options & PINYIN_AMB_S_SH) &&
+ ((lhs == CHEWING_S && rhs == CHEWING_SH) ||
+ (lhs == CHEWING_SH && rhs == CHEWING_S)))
+ return 0;
+
+ if ((options & PINYIN_AMB_Z_ZH) &&
+ ((lhs == CHEWING_Z && rhs == CHEWING_ZH) ||
+ (lhs == CHEWING_ZH && rhs == CHEWING_Z)))
+ return 0;
+
+ if ((options & PINYIN_AMB_F_H) &&
+ ((lhs == CHEWING_F && rhs == CHEWING_H) ||
+ (lhs == CHEWING_H && rhs == CHEWING_F)))
+ return 0;
+
+ if ((options & PINYIN_AMB_L_N) &&
+ ((lhs == CHEWING_L && rhs == CHEWING_N) ||
+ (lhs == CHEWING_N && rhs == CHEWING_L)))
+ return 0;
+
+ if ((options & PINYIN_AMB_L_R) &&
+ ((lhs == CHEWING_L && rhs == CHEWING_R) ||
+ (lhs == CHEWING_R && rhs == CHEWING_L)))
+ return 0;
+
+ if ((options & PINYIN_AMB_G_K) &&
+ ((lhs == CHEWING_G && rhs == CHEWING_K) ||
+ (lhs == CHEWING_K && rhs == CHEWING_G)))
+ return 0;
+
+ return (lhs - rhs);
+}
+
+int pinyin_compare_middle2 (guint32 options,
+ ChewingMiddle lhs,
+ ChewingMiddle rhs){
+ /* as no fuzzy pinyin option in chewing middle. */
+ return (lhs - rhs);
+}
+
+int pinyin_compare_final2 (guint32 options,
+ ChewingFinal lhs,
+ ChewingFinal rhs);
+
+int pinyin_compare_tone2 (guint32 options,
+ ChewingTone lhs,
+ ChewingTone rhs){
+ if (lhs == rhs)
+ return 0;
+ if (lhs == CHEWING_ZERO_TONE)
+ return 0;
+ if (rhs == CHEWING_ZERO_TONE)
+ return 0;
+ return (lhs - rhs);
+}
+
+
};
#endif