summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-04-08 11:52:24 +0800
committerPeng Wu <alexepico@gmail.com>2013-04-08 11:55:01 +0800
commit2b6bbbf8d0f60ed83aec91db3cc0c6796c079d29 (patch)
tree22b56345f405f0ed4f3506bea6a78a31d0824148 /src
parent415ccb56e84167f11bead9a1ca27be2e5216ba10 (diff)
downloadlibpinyin-2b6bbbf8d0f60ed83aec91db3cc0c6796c079d29.tar.gz
libpinyin-2b6bbbf8d0f60ed83aec91db3cc0c6796c079d29.tar.xz
libpinyin-2b6bbbf8d0f60ed83aec91db3cc0c6796c079d29.zip
fixes compile
Diffstat (limited to 'src')
-rw-r--r--src/include/novel_types.h11
-rw-r--r--src/storage/Makefile.am6
-rw-r--r--src/storage/phrase_index.cpp24
-rw-r--r--src/storage/phrase_index.h17
-rw-r--r--src/storage/table_info.cpp26
-rw-r--r--src/storage/table_info.h19
6 files changed, 37 insertions, 66 deletions
diff --git a/src/include/novel_types.h b/src/include/novel_types.h
index 6dcacb7..0ef845f 100644
--- a/src/include/novel_types.h
+++ b/src/include/novel_types.h
@@ -147,17 +147,6 @@ typedef enum {
GB_DICTIONARY = 1,
GBK_DICTIONARY = 2,
MERGED_DICTIONARY = 3,
- ART_DICTIONARY,
- CULTURE_DICTIONARY,
- ECONOMY_DICTIONARY,
- GEOLOGY_DICTIONARY,
- HISTORY_DICTIONARY,
- LIFE_DICTIONARY,
- NATURE_DICTIONARY,
- SCITECH_DICTIONARY,
- SOCIETY_DICTIONARY,
- SPORT_DICTIONARY,
- RESERVED1,
USER_DICTIONARY = 15
} PHRASE_INDEX_LIBRARIES;
diff --git a/src/storage/Makefile.am b/src/storage/Makefile.am
index 8e78568..d805f18 100644
--- a/src/storage/Makefile.am
+++ b/src/storage/Makefile.am
@@ -39,7 +39,8 @@ noinst_HEADERS = chewing_enum.h \
pinyin_phrase2.h \
chewing_large_table.h \
facade_chewing_table.h \
- facade_phrase_table2.h
+ facade_phrase_table2.h \
+ table_info.h
noinst_LTLIBRARIES = libstorage.la
@@ -53,5 +54,6 @@ libstorage_la_SOURCES = phrase_index.cpp \
ngram.cpp \
tag_utility.cpp \
pinyin_parser2.cpp \
- chewing_large_table.cpp
+ chewing_large_table.cpp \
+ table_info.cpp
diff --git a/src/storage/phrase_index.cpp b/src/storage/phrase_index.cpp
index c462fef..5f468b3 100644
--- a/src/storage/phrase_index.cpp
+++ b/src/storage/phrase_index.cpp
@@ -699,30 +699,6 @@ bool FacadePhraseIndex::mask_out(guint8 phrase_index,
}
namespace pinyin{
-const pinyin_table_info_t pinyin_phrase_files[PHRASE_INDEX_LIBRARY_COUNT] =
- {
- {RESERVED, NULL, NULL, NULL, NOT_USED},
- {GB_DICTIONARY, "gb_char.table", "gb_char.bin", "gb_char.dbin", SYSTEM_FILE},
- {GBK_DICTIONARY, "gbk_char.table", "gbk_char.bin", "gbk_char.dbin", SYSTEM_FILE},
-
- {MERGED_DICTIONARY, "merged.table", "merged.bin", "merged.dbin", SYSTEM_FILE},
-
- {ART_DICTIONARY, "art.table", "art.bin", "art.dbin", DICTIONARY},
- {CULTURE_DICTIONARY, "culture.table", "culture.bin", "culture.dbin", DICTIONARY},
- {ECONOMY_DICTIONARY, "economy.table", "economy.bin", "economy.dbin", DICTIONARY},
- {GEOLOGY_DICTIONARY, "geology.table", "geology.bin", "geology.dbin", DICTIONARY},
- {HISTORY_DICTIONARY, "history.table", "history.bin", "history.dbin", DICTIONARY},
-
- {LIFE_DICTIONARY, "life.table", "life.bin", "life.dbin", DICTIONARY},
- {NATURE_DICTIONARY, "nature.table", "nature.bin", "nature.dbin", DICTIONARY},
- {SCITECH_DICTIONARY, "scitech.table", "scitech.bin", "scitech.dbin", DICTIONARY},
- {SOCIETY_DICTIONARY, "society.table", "society.bin", "society.dbin", DICTIONARY},
- {SPORT_DICTIONARY, "sport.table", "sport.bin", "sport.dbin", DICTIONARY},
-
- {RESERVED1, NULL, NULL, NULL, NOT_USED},
-
- {USER_DICTIONARY, NULL, NULL, "user.bin", USER_FILE}
- };
static bool _peek_header(PhraseIndexLogger * logger,
diff --git a/src/storage/phrase_index.h b/src/storage/phrase_index.h
index 0ecfbec..e1dad0b 100644
--- a/src/storage/phrase_index.h
+++ b/src/storage/phrase_index.h
@@ -831,23 +831,6 @@ public:
}
};
-typedef enum {
- NOT_USED, /* not used. */
- SYSTEM_FILE, /* system phrase file. */
- DICTIONARY, /* professional dictionary. */
- USER_FILE, /* user only phrase file. */
-} PHRASE_FILE_TYPE;
-
-typedef struct {
- const guint8 m_dict_index; /* for assert purpose. */
- const char * m_table_filename;
- const char * m_system_filename;
- const char * m_user_filename;
- PHRASE_FILE_TYPE m_file_type;
-} pinyin_table_info_t;
-
-extern const pinyin_table_info_t pinyin_phrase_files[PHRASE_INDEX_LIBRARY_COUNT];
-
PhraseIndexLogger * mask_out_phrase_index_logger
(PhraseIndexLogger * oldlogger, phrase_token_t mask, phrase_token_t value);
diff --git a/src/storage/table_info.cpp b/src/storage/table_info.cpp
index 12cd970..fd2d2f4 100644
--- a/src/storage/table_info.cpp
+++ b/src/storage/table_info.cpp
@@ -22,6 +22,7 @@
#include "table_info.h"
#include <stdio.h>
#include <assert.h>
+#include <string.h>
using namespace pinyin;
@@ -67,12 +68,13 @@ void SystemTableInfo::reset() {
for (i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
pinyin_table_info_t * tableinfo = &m_table_info[i];
- g_free(tableinfo->m_table_filename);
+ g_free((gchar *)tableinfo->m_table_filename);
tableinfo->m_table_filename = NULL;
- g_free(tableinfo->m_system_filename);
+ g_free((gchar *)tableinfo->m_system_filename);
tableinfo->m_system_filename = NULL;
- g_free(tableinfo->m_user_filename);
+ g_free((gchar *)tableinfo->m_user_filename);
tableinfo->m_user_filename = NULL;
+
tableinfo->m_file_type = NOT_USED;
}
}
@@ -80,7 +82,7 @@ void SystemTableInfo::reset() {
void SystemTableInfo::postfix_tables() {
size_t i;
for (i = 0; i < G_N_ELEMENTS(reserved_tables); ++i) {
- pinyin_table_info_t * postfix = &reserved_tables[i];
+ const pinyin_table_info_t * postfix = &reserved_tables[i];
guint8 index = postfix->m_dict_index;
pinyin_table_info_t * tableinfo = &m_table_info[index];
@@ -150,8 +152,8 @@ bool SystemTableInfo::load(const char * filename) {
int index = 0;
char tablefile[256], sysfile[256], userfile[256], filetype[256];
- while (!feof(infile)){
- num = fscanf("%d %s %s %s %s",
+ while (!feof(input)) {
+ num = fscanf(input, "%d %s %s %s %s",
&index, tablefile, sysfile, userfile, filetype);
if (5 != num)
@@ -164,11 +166,11 @@ bool SystemTableInfo::load(const char * filename) {
pinyin_table_info_t * tableinfo = &m_table_info[index];
assert(index == tableinfo->m_dict_index);
- table_info->m_table_filename = to_string(tablefile);
- table_info->m_system_filename = to_string(sysfile);
- table_info->m_user_filename = to_string(userfile);
+ tableinfo->m_table_filename = to_string(tablefile);
+ tableinfo->m_system_filename = to_string(sysfile);
+ tableinfo->m_user_filename = to_string(userfile);
- table_info->m_file_type = to_file_type(filetype);
+ tableinfo->m_file_type = to_file_type(filetype);
}
fclose(input);
@@ -197,7 +199,7 @@ void UserTableInfo::reset() {
m_model_data_version = 0;
}
-bool UserTableInfo::load(cosnt char * filename) {
+bool UserTableInfo::load(const char * filename) {
reset();
FILE * input = fopen(filename, "r");
@@ -231,7 +233,7 @@ bool UserTableInfo::load(cosnt char * filename) {
bool UserTableInfo::save(const char * filename) {
FILE * output = fopen(filename, "w");
if (NULL == output) {
- fprintf(stderr, "write %s failed.\n", output);
+ fprintf(stderr, "write %s failed.\n", filename);
return false;
}
diff --git a/src/storage/table_info.h b/src/storage/table_info.h
index 8feee95..8d7fa05 100644
--- a/src/storage/table_info.h
+++ b/src/storage/table_info.h
@@ -22,8 +22,27 @@
#ifndef TABLE_INFO_H
#define TABLE_INFO_H
+#include "novel_types.h"
+
+
namespace pinyin{
+typedef enum {
+ NOT_USED, /* not used. */
+ SYSTEM_FILE, /* system phrase file. */
+ DICTIONARY, /* professional dictionary. */
+ USER_FILE, /* user only phrase file. */
+} PHRASE_FILE_TYPE;
+
+typedef struct {
+ guint8 m_dict_index; /* for assert purpose. */
+ const gchar * m_table_filename;
+ const gchar * m_system_filename;
+ const gchar * m_user_filename;
+ PHRASE_FILE_TYPE m_file_type;
+} pinyin_table_info_t;
+
+
class UserTableInfo;
class SystemTableInfo{