summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2017-05-25 15:36:40 +0800
committerPeng Wu <alexepico@gmail.com>2017-05-25 15:36:40 +0800
commitcfe42385affbe99c5e4b01d2a8d7ef9d6f72d425 (patch)
tree6976cba0a15b7c20fa36deb9194c3fb47f9af72d
parent0bd9779cfd4be55ec600355c31806279885ba754 (diff)
downloadlibpinyin-cfe42385affbe99c5e4b01d2a8d7ef9d6f72d425.tar.gz
libpinyin-cfe42385affbe99c5e4b01d2a8d7ef9d6f72d425.tar.xz
libpinyin-cfe42385affbe99c5e4b01d2a8d7ef9d6f72d425.zip
handle zhuyin table file in tests and utils
-rw-r--r--tests/storage/test_chewing_table.cpp4
-rw-r--r--tests/storage/test_phrase_index.cpp4
-rw-r--r--tests/storage/test_phrase_table.cpp4
-rw-r--r--tests/tests_helper.h7
-rw-r--r--utils/storage/gen_binary_files.cpp12
5 files changed, 20 insertions, 11 deletions
diff --git a/tests/storage/test_chewing_table.cpp b/tests/storage/test_chewing_table.cpp
index f417c65..7c9f28e 100644
--- a/tests/storage/test_chewing_table.cpp
+++ b/tests/storage/test_chewing_table.cpp
@@ -45,7 +45,9 @@ int main(int argc, char * argv[]) {
const pinyin_table_info_t * phrase_files =
system_table_info.get_default_tables();
- if (!load_phrase_table(phrase_files, &largetable, NULL, &phrase_index))
+ TABLE_PHONETIC_TYPE type = system_table_info.get_table_phonetic_type();
+ if (!load_phrase_table(phrase_files, &largetable,
+ NULL, &phrase_index, type))
exit(ENOENT);
#if 0
diff --git a/tests/storage/test_phrase_index.cpp b/tests/storage/test_phrase_index.cpp
index ddfea8a..fa0721a 100644
--- a/tests/storage/test_phrase_index.cpp
+++ b/tests/storage/test_phrase_index.cpp
@@ -83,7 +83,9 @@ int main(int argc, char * argv[]){
const pinyin_table_info_t * phrase_files =
system_table_info.get_default_tables();
- if (!load_phrase_table(phrase_files, NULL, NULL, &phrase_index))
+ TABLE_PHONETIC_TYPE type = system_table_info.get_table_phonetic_type();
+ if (!load_phrase_table(phrase_files, NULL,
+ NULL, &phrase_index, type))
exit(ENOENT);
phrase_index.compact();
diff --git a/tests/storage/test_phrase_table.cpp b/tests/storage/test_phrase_table.cpp
index 041588d..66e497f 100644
--- a/tests/storage/test_phrase_table.cpp
+++ b/tests/storage/test_phrase_table.cpp
@@ -24,7 +24,9 @@ int main(int argc, char * argv[]){
const pinyin_table_info_t * phrase_files =
system_table_info.get_default_tables();
- if (!load_phrase_table(phrase_files, NULL, &largetable, &phrase_index))
+ TABLE_PHONETIC_TYPE type = system_table_info.get_table_phonetic_type();
+ if (!load_phrase_table(phrase_files, NULL,
+ &largetable, &phrase_index, type))
exit(ENOENT);
#if 0
diff --git a/tests/tests_helper.h b/tests/tests_helper.h
index 9177956..b236cd7 100644
--- a/tests/tests_helper.h
+++ b/tests/tests_helper.h
@@ -51,7 +51,8 @@ inline bool load_phrase_index(const pinyin_table_info_t * phrase_files,
inline bool load_phrase_table(const pinyin_table_info_t * phrase_files,
ChewingLargeTable2 * chewing_table,
PhraseLargeTable3 * phrase_table,
- FacadePhraseIndex * phrase_index){
+ FacadePhraseIndex * phrase_index,
+ TABLE_PHONETIC_TYPE type){
for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
const pinyin_table_info_t * table_info = phrase_files + i;
@@ -70,13 +71,13 @@ inline bool load_phrase_table(const pinyin_table_info_t * phrase_files,
g_free(filename);
if (chewing_table)
- chewing_table->load_text(tablefile);
+ chewing_table->load_text(tablefile, type);
fseek(tablefile, 0L, SEEK_SET);
if (phrase_table)
phrase_table->load_text(tablefile);
fseek(tablefile, 0L, SEEK_SET);
if (phrase_index)
- phrase_index->load_text(i, tablefile);
+ phrase_index->load_text(i, tablefile, type);
fclose(tablefile);
}
return true;
diff --git a/utils/storage/gen_binary_files.cpp b/utils/storage/gen_binary_files.cpp
index 967ae95..fe73d75 100644
--- a/utils/storage/gen_binary_files.cpp
+++ b/utils/storage/gen_binary_files.cpp
@@ -33,7 +33,8 @@ static GOptionEntry entries[] =
bool generate_binary_files(const char * pinyin_table_filename,
const char * phrase_table_filename,
- const pinyin_table_info_t * phrase_files) {
+ const pinyin_table_info_t * phrase_files,
+ TABLE_PHONETIC_TYPE type) {
/* generate pinyin index*/
ChewingLargeTable2 pinyin_table;
pinyin_table.attach(pinyin_table_filename, ATTACH_READWRITE|ATTACH_CREATE);
@@ -62,11 +63,11 @@ bool generate_binary_files(const char * pinyin_table_filename,
exit(ENOENT);
}
- pinyin_table.load_text(tablefile);
+ pinyin_table.load_text(tablefile, type);
fseek(tablefile, 0L, SEEK_SET);
phrase_table.load_text(tablefile);
fseek(tablefile, 0L, SEEK_SET);
- phrase_index.load_text(i, tablefile);
+ phrase_index.load_text(i, tablefile, type);
fclose(tablefile);
g_free(filename);
}
@@ -108,15 +109,16 @@ int main(int argc, char * argv[]){
const pinyin_table_info_t * phrase_files =
system_table_info.get_default_tables();
+ TABLE_PHONETIC_TYPE type = system_table_info.get_table_phonetic_type();
generate_binary_files(SYSTEM_PINYIN_INDEX,
SYSTEM_PHRASE_INDEX,
- phrase_files);
+ phrase_files, type);
phrase_files = system_table_info.get_addon_tables();
generate_binary_files(ADDON_SYSTEM_PINYIN_INDEX,
ADDON_SYSTEM_PHRASE_INDEX,
- phrase_files);
+ phrase_files, type);
return 0;
}