summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-12-02 11:08:09 +0800
committerPeng Wu <alexepico@gmail.com>2011-12-02 11:08:09 +0800
commit6db008752cfad90cd6c839f1776429ecee68948d (patch)
treecd3737ae7f8fa67aee7a297da17a0aa49db17f27
parent1e9eafd096f28e88766d5cf26c1ccf4b336a1706 (diff)
downloadlibpinyin-6db008752cfad90cd6c839f1776429ecee68948d.tar.gz
libpinyin-6db008752cfad90cd6c839f1776429ecee68948d.tar.xz
libpinyin-6db008752cfad90cd6c839f1776429ecee68948d.zip
fixes double pinyin parser
-rw-r--r--src/storage/pinyin_parser2.cpp4
-rw-r--r--tests/storage/test_parser2.cpp2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp
index 568380c..7e98b4d 100644
--- a/src/storage/pinyin_parser2.cpp
+++ b/src/storage/pinyin_parser2.cpp
@@ -23,6 +23,7 @@
#include "pinyin_parser2.h"
#include <ctype.h>
#include <assert.h>
+#include <stdio.h>
#include <string.h>
#include "stl_lite.h"
#include "pinyin_phrase2.h"
@@ -528,7 +529,8 @@ int DoublePinyinParser2::parse(pinyin_option_t options, ChewingKeyVector & keys,
int maximum_len = 0; int i;
/* probe the longest possible double pinyin string. */
for (i = 0; i < len; ++i) {
- if (!IS_KEY(str[i]))
+ const char ch = str[i];
+ if (!(IS_KEY(ch) || ('0' < ch && ch <= '5')))
break;
}
maximum_len = i;
diff --git a/tests/storage/test_parser2.cpp b/tests/storage/test_parser2.cpp
index 3748338..f42db49 100644
--- a/tests/storage/test_parser2.cpp
+++ b/tests/storage/test_parser2.cpp
@@ -56,7 +56,7 @@ int main(int argc, char * argv[]) {
ChewingKeyVector keys = g_array_new(FALSE, FALSE, sizeof(ChewingKey));
ChewingKeyRestVector key_rests =
g_array_new(FALSE, FALSE, sizeof(ChewingKeyRest));
- pinyin_option_t options = PINYIN_CORRECT_ALL | USE_RESPLIT_TABLE;
+ pinyin_option_t options = PINYIN_CORRECT_ALL | USE_TONE | USE_RESPLIT_TABLE;
int i = 1;
while(i < argc) {