summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/storage/phonetic_key_matrix.cpp46
-rw-r--r--tests/storage/test_matrix.cpp3
2 files changed, 27 insertions, 22 deletions
diff --git a/src/storage/phonetic_key_matrix.cpp b/src/storage/phonetic_key_matrix.cpp
index 693753e..af5b1a0 100644
--- a/src/storage/phonetic_key_matrix.cpp
+++ b/src/storage/phonetic_key_matrix.cpp
@@ -88,17 +88,18 @@ bool fuzzy_syllable_step(pinyin_option_t options,
size_t i = 0;
for (i = 0; i < keys->len; ++i) {
- ChewingKey key = g_array_index(keys, ChewingKey, i);
- ChewingKeyRest key_rest = g_array_index(key_rests,
- ChewingKeyRest, i);
-
-#define MATCH(AMBIGUITY, ORIGIN, ANOTHER) do { \
- if (options & AMBIGUITY) { \
- if (ORIGIN == key.m_initial) { \
- key.m_initial = ANOTHER; \
- matrix->append(index, key, key_rest); \
- } \
- } \
+ const ChewingKey key = g_array_index(keys, ChewingKey, i);
+ const ChewingKeyRest key_rest = g_array_index(key_rests,
+ ChewingKeyRest, i);
+
+#define MATCH(AMBIGUITY, ORIGIN, ANOTHER) do { \
+ if (options & AMBIGUITY) { \
+ if (ORIGIN == key.m_initial) { \
+ ChewingKey newkey = key; \
+ newkey.m_initial = ANOTHER; \
+ matrix->append(index, newkey, key_rest); \
+ } \
+ } \
} while (0)
@@ -127,17 +128,18 @@ bool fuzzy_syllable_step(pinyin_option_t options,
assert(0 != keys->len);
for (i = 0; i < keys->len; ++i) {
- ChewingKey key = g_array_index(keys, ChewingKey, i);
- ChewingKeyRest key_rest = g_array_index(key_rests,
- ChewingKeyRest, i);
-
-#define MATCH(AMBIGUITY, ORIGIN, ANOTHER) do { \
- if (options & AMBIGUITY) { \
- if (ORIGIN == key.m_final) { \
- key.m_final = ANOTHER; \
- matrix->append(index, key, key_rest); \
- } \
- } \
+ const ChewingKey key = g_array_index(keys, ChewingKey, i);
+ const ChewingKeyRest key_rest = g_array_index(key_rests,
+ ChewingKeyRest, i);
+
+#define MATCH(AMBIGUITY, ORIGIN, ANOTHER) do { \
+ if (options & AMBIGUITY) { \
+ if (ORIGIN == key.m_final) { \
+ ChewingKey newkey = key; \
+ newkey.m_final = ANOTHER; \
+ matrix->append(index, newkey, key_rest); \
+ } \
+ } \
} while (0)
diff --git a/tests/storage/test_matrix.cpp b/tests/storage/test_matrix.cpp
index fd965b8..3bf787d 100644
--- a/tests/storage/test_matrix.cpp
+++ b/tests/storage/test_matrix.cpp
@@ -29,6 +29,7 @@ using namespace pinyin;
int main(int argc, char * argv[]) {
pinyin_option_t options = PINYIN_CORRECT_ALL;
+ options |= PINYIN_AMB_ALL;
options |= PINYIN_INCOMPLETE;
PhoneticParser2 * parser = new FullPinyinParser2();
@@ -57,6 +58,8 @@ int main(int argc, char * argv[]) {
fill_phonetic_key_matrix_from_chewing_keys
(&matrix, keys, key_rests);
+
+ fuzzy_syllable_step(options, &matrix);
}
print_time(start_time, bench_times);