diff options
author | Peng Wu <alexepico@gmail.com> | 2015-05-20 14:28:51 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2015-05-20 14:28:51 +0800 |
commit | 42c7299f3bbe2191a44aa17fe17829361aede7eb (patch) | |
tree | 33f52ede9795c06ee500eaa4366c8a77ca2c656b | |
parent | 8fc2fc4da82250bfe33c81c3575cb4d5fdde10dc (diff) | |
download | libpinyin-42c7299f3bbe2191a44aa17fe17829361aede7eb.tar.gz libpinyin-42c7299f3bbe2191a44aa17fe17829361aede7eb.tar.xz libpinyin-42c7299f3bbe2191a44aa17fe17829361aede7eb.zip |
add phonetic table type to table info
-rw-r--r-- | src/include/novel_types.h | 4 | ||||
-rw-r--r-- | src/storage/table_info.cpp | 15 | ||||
-rw-r--r-- | src/storage/table_info.h | 9 |
3 files changed, 27 insertions, 1 deletions
diff --git a/src/include/novel_types.h b/src/include/novel_types.h index 88c063c..f2211c0 100644 --- a/src/include/novel_types.h +++ b/src/include/novel_types.h @@ -147,7 +147,9 @@ typedef enum { GB_DICTIONARY = 1, GBK_DICTIONARY = 2, MERGED_DICTIONARY = 3, - USER_DICTIONARY = 15 + ADDON_DICTIONARY = 4, + NETWORK_DICTIONARY = 5, + USER_DICTIONARY = 6 } PHRASE_INDEX_LIBRARIES; G_END_DECLS diff --git a/src/storage/table_info.cpp b/src/storage/table_info.cpp index 6d1159a..ea10df9 100644 --- a/src/storage/table_info.cpp +++ b/src/storage/table_info.cpp @@ -21,6 +21,7 @@ #include "table_info.h" #include <stdio.h> +#include <stdlib.h> #include <assert.h> #include <string.h> #include <locale.h> @@ -44,6 +45,8 @@ SystemTableInfo::SystemTableInfo() { m_model_data_version = 0; m_lambda = 0.; + m_table_phonetic_type = PINYIN_TABLE; + size_t i; for (i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) { pinyin_table_info_t * table_info = &m_table_info[i]; @@ -65,6 +68,8 @@ void SystemTableInfo::reset() { m_model_data_version = 0; m_lambda = 0.; + m_table_phonetic_type = PINYIN_TABLE; + size_t i; for (i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) { pinyin_table_info_t * table_info = &m_table_info[i]; @@ -151,8 +156,18 @@ bool SystemTableInfo::load(const char * filename) { return false; } + TABLE_PHONETIC_TYPE type = PINYIN_TABLE; + char * str = NULL; + num = fscanf(input, "source table format:%ms", &str); + if (0 == strcmp("pinyin", str)) + type = PINYIN_TABLE; + if (0 == strcmp("zhuyin", str)) + type = ZHUYIN_TABLE; + free(str); + #if 0 printf("binver:%d modelver:%d lambda:%f\n", binver, modelver, lambda); + printf("type:%d\n", type); #endif m_binary_format_version = binver; diff --git a/src/storage/table_info.h b/src/storage/table_info.h index 8d7fa05..ff7a781 100644 --- a/src/storage/table_info.h +++ b/src/storage/table_info.h @@ -28,6 +28,11 @@ namespace pinyin{ typedef enum { + PINYIN_TABLE, /* use pinyin. */ + ZHUYIN_TABLE, /* use zhuyin. */ +} TABLE_PHONETIC_TYPE; + +typedef enum { NOT_USED, /* not used. */ SYSTEM_FILE, /* system phrase file. */ DICTIONARY, /* professional dictionary. */ @@ -52,6 +57,8 @@ private: int m_model_data_version; gfloat m_lambda; + TABLE_PHONETIC_TYPE m_table_phonetic_type; + pinyin_table_info_t m_table_info[PHRASE_INDEX_LIBRARY_COUNT]; private: @@ -69,6 +76,8 @@ public: const pinyin_table_info_t * get_table_info(); gfloat get_lambda(); + + TABLE_PHONETIC_TYPE get_table_phonetic_type(); }; class UserTableInfo{ |