summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-08-08 13:44:49 +0800
committerPeng Wu <alexepico@gmail.com>2011-08-08 13:44:49 +0800
commit1dab453f2326a9ad2c8b03ca1a26e5bac6906bb8 (patch)
treef0ff2c445dce8db539d9e94f6d532764fe1052f3
parent3aaa518dce7f164b2b758f1c3502b3fa6dde97d0 (diff)
downloadlibpinyin-1dab453f2326a9ad2c8b03ca1a26e5bac6906bb8.tar.gz
libpinyin-1dab453f2326a9ad2c8b03ca1a26e5bac6906bb8.tar.xz
libpinyin-1dab453f2326a9ad2c8b03ca1a26e5bac6906bb8.zip
add Ge<=>Ke fuzzy pinyin
-rw-r--r--src/storage/pinyin_base.cpp10
-rw-r--r--src/storage/pinyin_base.h5
-rw-r--r--src/storage/pinyin_large_table.cpp2
3 files changed, 12 insertions, 5 deletions
diff --git a/src/storage/pinyin_base.cpp b/src/storage/pinyin_base.cpp
index c12c7ba..e7715a0 100644
--- a/src/storage/pinyin_base.cpp
+++ b/src/storage/pinyin_base.cpp
@@ -60,8 +60,8 @@ static const PinyinToken __pinyin_initials[] =
{"f", "ㄈ", 1, 1},
{"h", "ㄏ", 1, 1},
{"g", "ㄍ", 1, 1},
- {"j", "ㄐ", 1, 1},
{"k", "ㄎ", 1, 1},
+ {"j", "ㄐ", 1, 1},
{"m", "ㄇ", 1, 1},
{"n", "ㄋ", 1, 1},
{"l", "ㄌ", 1, 1},
@@ -135,7 +135,7 @@ static const PinyinToken __pinyin_tones [] =
static const PinyinTokenIndex __pinyin_initials_index[] =
{
//a b c d e f g h i j k l m
- {-1,0},{1,1}, {2,2}, {4,1}, {-1,0},{5,1}, {7,1}, {6,1}, {-1,0},{8,1}, {9,1}, {12,1},{10,1},
+ {-1,0},{1,1}, {2,2}, {4,1}, {-1,0},{5,1}, {7,1}, {6,1}, {-1,0},{9,1}, {8,1}, {12,1},{10,1},
//n o p q r s t u v w x y z
{11,1},{-1,0},{14,1},{15,1},{13,1},{16,2},{18,1},{-1,0},{-1,0},{19,1},{20,1},{21,1},{22,2}
};
@@ -1381,7 +1381,11 @@ int pinyin_compare_initial (const PinyinCustomSettings &custom,
(custom.use_ambiguities [PINYIN_AmbFoHe] &&
((lhs == PINYIN_Fo && rhs == PINYIN_He) ||
- (lhs == PINYIN_He && rhs == PINYIN_Fo)))
+ (lhs == PINYIN_He && rhs == PINYIN_Fo))) ||
+
+ (custom.use_ambiguities [PINYIN_AmbGeKe] &&
+ ((lhs == PINYIN_Ge && rhs == PINYIN_Ke) ||
+ (lhs == PINYIN_Ke && rhs == PINYIN_Ge)))
)
return 0;
else return (lhs - rhs);
diff --git a/src/storage/pinyin_base.h b/src/storage/pinyin_base.h
index 4c15454..14d3a99 100644
--- a/src/storage/pinyin_base.h
+++ b/src/storage/pinyin_base.h
@@ -84,8 +84,8 @@ enum PinyinInitial
PINYIN_Fo = 5,
PINYIN_He = 6,
PINYIN_Ge = 7,
- PINYIN_Ji = 8,
- PINYIN_Ke = 9,
+ PINYIN_Ke = 8,
+ PINYIN_Ji = 9,
PINYIN_Mo =10,
PINYIN_Ne =11,
PINYIN_Le =12,
@@ -213,6 +213,7 @@ enum PinyinAmbiguity
PINYIN_AmbNeLe,
PINYIN_AmbLeRi,
PINYIN_AmbFoHe,
+ PINYIN_AmbGeKe,
PINYIN_AmbAnAng,
PINYIN_AmbEnEng,
PINYIN_AmbInIng,
diff --git a/src/storage/pinyin_large_table.cpp b/src/storage/pinyin_large_table.cpp
index c098ece..d9094a5 100644
--- a/src/storage/pinyin_large_table.cpp
+++ b/src/storage/pinyin_large_table.cpp
@@ -130,6 +130,8 @@ int PinyinBitmapIndexLevel::initial_level_search(int phrase_length,
MATCH(PINYIN_AmbNeLe, PINYIN_Ne, PINYIN_Le);
MATCH(PINYIN_AmbFoHe, PINYIN_Fo, PINYIN_He);
MATCH(PINYIN_AmbFoHe, PINYIN_He, PINYIN_Fo);
+ MATCH(PINYIN_AmbGeKe, PINYIN_Ge, PINYIN_Ke);
+ MATCH(PINYIN_AmbGeKe, PINYIN_Ke, PINYIN_Ge);
case PINYIN_Le:
{