summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-04-01 11:03:46 +0800
committerPeng Wu <alexepico@gmail.com>2011-04-02 15:11:18 +0800
commitf1f777630f85e58b01b472da23e3f72a71dd1f49 (patch)
tree5f41f2bd66ef04b41950a9a67ee39459dd46b587 /src
parent37498f130e673dcb3052c029c0407ffa483dda8a (diff)
downloadlibpinyin-f1f777630f85e58b01b472da23e3f72a71dd1f49.tar.gz
libpinyin-f1f777630f85e58b01b472da23e3f72a71dd1f49.tar.xz
libpinyin-f1f777630f85e58b01b472da23e3f72a71dd1f49.zip
refine code
Diffstat (limited to 'src')
-rw-r--r--src/storage/flexible_ngram.h10
-rw-r--r--src/storage/ngram.cpp8
-rw-r--r--src/storage/ngram.h4
3 files changed, 16 insertions, 6 deletions
diff --git a/src/storage/flexible_ngram.h b/src/storage/flexible_ngram.h
index f437b80..9bcfdc3 100644
--- a/src/storage/flexible_ngram.h
+++ b/src/storage/flexible_ngram.h
@@ -19,6 +19,12 @@ private:
MemoryChunk m_chunk;
FlexibleSingleGram(void * buffer, size_t length);
public:
+ /* item typedefs */
+ typedef struct{
+ phrase_token_t m_token;
+ ArrayItem m_item;
+ } ArrayItemWithToken;
+
/* Null Constructor */
FlexibleSingleGram();
/* retrieve all items */
@@ -73,6 +79,10 @@ public:
bool store(phrase_token_t index, FlexibleSingleGram * & single_gram);
/* array of phrase_token_t items, for parameter estimation. */
bool get_all_items(GArray * items);
+
+ /* get/set magic header. */
+ bool get_magic_header(MagicHeader & header);
+ bool set_magic_header(const MagicHeader & header);
};
#endif
diff --git a/src/storage/ngram.cpp b/src/storage/ngram.cpp
index 8ea8334..c6b1736 100644
--- a/src/storage/ngram.cpp
+++ b/src/storage/ngram.cpp
@@ -38,15 +38,15 @@ SingleGram::SingleGram(void * buffer, size_t length){
m_chunk.set_chunk(buffer, length, NULL);
}
-bool SingleGram::set_total_freq(guint32 m_total){
+bool SingleGram::set_total_freq(guint32 total){
char * buf_begin = (char *)m_chunk.begin();
- *((guint32 *)buf_begin) = m_total;
+ *((guint32 *)buf_begin) = total;
return true;
}
-bool SingleGram::get_total_freq(guint32 & m_total){
+bool SingleGram::get_total_freq(guint32 & total){
char * buf_begin = (char *)m_chunk.begin();
- m_total = *((guint32 *)buf_begin);
+ total = *((guint32 *)buf_begin);
return true;
}
diff --git a/src/storage/ngram.h b/src/storage/ngram.h
index c4fdf7b..c5e7bc8 100644
--- a/src/storage/ngram.h
+++ b/src/storage/ngram.h
@@ -66,12 +66,12 @@ public:
/* get_total_freq method
* used in user bigram table
*/
- bool get_total_freq(guint32 & m_total);
+ bool get_total_freq(guint32 & total);
/* set_total_freq method
* used in user bigram table
*/
- bool set_total_freq(guint32 m_total);
+ bool set_total_freq(guint32 total);
/* prune one method
* only used in training