summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2024-09-24 14:33:12 +0800
committerPeng Wu <alexepico@gmail.com>2024-09-24 14:33:12 +0800
commit17b616cbc44dcdf662edb665e0f3ddee9d065070 (patch)
treece62769d523f79dad61a82bf39a3f391b09d981d
parent53cc359bb90f2c50e818297ff43e8e36c6a57310 (diff)
downloadlibpinyin-17b616cbc44dcdf662edb665e0f3ddee9d065070.tar.gz
libpinyin-17b616cbc44dcdf662edb665e0f3ddee9d065070.tar.xz
libpinyin-17b616cbc44dcdf662edb665e0f3ddee9d065070.zip
Fix compile
-rw-r--r--src/pinyin_internal.h2
-rw-r--r--src/storage/punct_table.cpp4
-rw-r--r--src/storage/punct_table.h1
-rw-r--r--src/storage/punct_table_bdb.cpp18
-rw-r--r--src/storage/punct_table_kyotodb.cpp14
-rw-r--r--src/storage/punct_table_kyotodb.h1
6 files changed, 21 insertions, 19 deletions
diff --git a/src/pinyin_internal.h b/src/pinyin_internal.h
index 44b455f..db6a8e4 100644
--- a/src/pinyin_internal.h
+++ b/src/pinyin_internal.h
@@ -44,6 +44,7 @@
#include "phrase_lookup.h"
#include "tag_utility.h"
#include "table_info.h"
+#include "punct_table.h"
/* training module */
@@ -62,6 +63,7 @@
#define USER_PHRASE_INDEX "user_phrase_index.bin"
#define ADDON_SYSTEM_PINYIN_INDEX "addon_pinyin_index.bin"
#define ADDON_SYSTEM_PHRASE_INDEX "addon_phrase_index.bin"
+#define SYSTEM_PUNCT_TABLE "punct.db"
using namespace pinyin;
diff --git a/src/storage/punct_table.cpp b/src/storage/punct_table.cpp
index d901ded..184be92 100644
--- a/src/storage/punct_table.cpp
+++ b/src/storage/punct_table.cpp
@@ -35,7 +35,7 @@ PunctTableEntry::~PunctTableEntry() {
m_utf8_cache = NULL;
}
-bool PunctTableEntry::escape(const gchar * punct, gint maxlen = -1) {
+bool PunctTableEntry::escape(const gchar * punct, gint maxlen) {
if (maxlen == -1)
maxlen = G_MAXINT;
@@ -54,7 +54,7 @@ bool PunctTableEntry::escape(const gchar * punct, gint maxlen = -1) {
return true;
}
-int PunctTableEntry::unescape(const ucs4_t * punct, gint maxlen = -1) {
+int PunctTableEntry::unescape(const ucs4_t * punct, gint maxlen) {
if (maxlen == -1)
maxlen = G_MAXINT;
diff --git a/src/storage/punct_table.h b/src/storage/punct_table.h
index 33926c2..256fd7b 100644
--- a/src/storage/punct_table.h
+++ b/src/storage/punct_table.h
@@ -23,6 +23,7 @@
#define PUNCT_TABLE_H
#include <glib.h>
+#include "novel_types.h"
#include "memory_chunk.h"
#ifdef HAVE_BERKELEY_DB
diff --git a/src/storage/punct_table_bdb.cpp b/src/storage/punct_table_bdb.cpp
index d0e3386..3908dda 100644
--- a/src/storage/punct_table_bdb.cpp
+++ b/src/storage/punct_table_bdb.cpp
@@ -94,7 +94,7 @@ bool PunctTable::load_db(const char * dbfile) {
if (NULL == tmp_db)
return false;
- ret = tmp_db->open(tmp_db, NULL, filename, NULL,
+ ret = tmp_db->open(tmp_db, NULL, dbfile, NULL,
DB_BTREE, DB_RDONLY, 0600);
if (ret != 0)
return false;
@@ -111,7 +111,7 @@ bool PunctTable::load_db(const char * dbfile) {
bool PunctTable::save_db(const char * dbfile) {
DB * tmp_db = NULL;
- int ret = unlink(new_filename);
+ int ret = unlink(dbfile);
if (ret != 0 && errno != ENOENT)
return false;
@@ -121,7 +121,7 @@ bool PunctTable::save_db(const char * dbfile) {
if (NULL == tmp_db)
return false;
- ret = tmp_db->open(tmp_db, NULL, new_filename, NULL,
+ ret = tmp_db->open(tmp_db, NULL, dbfile, NULL,
DB_BTREE, DB_CREATE, 0600);
if (ret != 0)
return false;
@@ -173,7 +173,7 @@ bool PunctTable::store_entry(phrase_token_t index) {
memset(&db_data, 0, sizeof(DBT));
db_data.data = m_entry->m_chunk.begin();
db_data.size = m_entry->m_chunk.size();
- ret = m_db->put(m_db, NULL, &db_key, &db_data, 0);
+ int ret = m_db->put(m_db, NULL, &db_key, &db_data, 0);
if (ret != 0)
return false;
return true;
@@ -183,7 +183,7 @@ bool PunctTable::get_all_punctuations(/* in */ phrase_token_t index,
/* out */ gchar ** & puncts) {
assert(NULL == puncts);
- if (!load_entry())
+ if (!load_entry(index))
return false;
return m_entry->get_all_punctuations(puncts);
@@ -191,22 +191,22 @@ bool PunctTable::get_all_punctuations(/* in */ phrase_token_t index,
bool PunctTable::append_punctuation(/* in */ phrase_token_t index,
/* in */ const gchar * punct) {
- if (!load_entry())
+ if (!load_entry(index))
return false;
if (!m_entry->append_punctuation(punct))
return false;
- if (!store_entry())
+ if (!store_entry(index))
return false;
return true;
}
bool PunctTable::remove_punctuation(/* in */ phrase_token_t index,
/* in */ const gchar * punct) {
- if (!load_entry())
+ if (!load_entry(index))
return false;
if (!m_entry->remove_punctuation(punct))
return false;
- if (!store_entry())
+ if (!store_entry(index))
return false;
return true;
}
diff --git a/src/storage/punct_table_kyotodb.cpp b/src/storage/punct_table_kyotodb.cpp
index 517abb0..bfa5d6c 100644
--- a/src/storage/punct_table_kyotodb.cpp
+++ b/src/storage/punct_table_kyotodb.cpp
@@ -64,7 +64,7 @@ bool PunctTable::attach(const char * dbfile, guint32 flags) {
return m_db->open(dbfile, mode);
}
-/* load_db/store_db method */
+/* load_db/save_db method */
/* use in-memory DBM here, for better performance. */
bool PunctTable::load_db(const char * filename) {
reset();
@@ -83,7 +83,7 @@ bool PunctTable::load_db(const char * filename) {
return true;
}
-bool PunctTable::store_db(const char * new_filename) {
+bool PunctTable::save_db(const char * new_filename) {
int ret = unlink(new_filename);
if ( ret != 0 && errno != ENOENT)
return false;
@@ -130,7 +130,7 @@ bool PunctTable::get_all_punctuations(/* in */ phrase_token_t index,
/* out */ gchar ** & puncts) {
assert(NULL == puncts);
- if (!load_entry())
+ if (!load_entry(index))
return false;
return m_entry->get_all_punctuations(puncts);
@@ -138,22 +138,22 @@ bool PunctTable::get_all_punctuations(/* in */ phrase_token_t index,
bool PunctTable::append_punctuation(/* in */ phrase_token_t index,
/* in */ const gchar * punct) {
- if (!load_entry())
+ if (!load_entry(index))
return false;
if (!m_entry->append_punctuation(punct))
return false;
- if (!store_entry())
+ if (!store_entry(index))
return false;
return true;
}
bool PunctTable::remove_punctuation(/* in */ phrase_token_t index,
/* in */ const gchar * punct) {
- if (!load_entry())
+ if (!load_entry(index))
return false;
if (!m_entry->remove_punctuation(punct))
return false;
- if (!store_entry())
+ if (!store_entry(index))
return false;
return true;
}
diff --git a/src/storage/punct_table_kyotodb.h b/src/storage/punct_table_kyotodb.h
index be0ccd3..c030bff 100644
--- a/src/storage/punct_table_kyotodb.h
+++ b/src/storage/punct_table_kyotodb.h
@@ -23,7 +23,6 @@
#define PUNCT_TABLE_KYOTODB_H
#include <kcdb.h>
-#include "memory_chunk.h"
namespace pinyin{