summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-01-21 13:29:19 +0800
committerPeng Wu <alexepico@gmail.com>2016-01-21 13:29:19 +0800
commita7526ca001e88457c290547bd42315bd4bb876be (patch)
tree8f63aaa3cf207f249f9a7d1f9d1efa60721b8c86
parent9b3aad3a507b98bbccad3b37f97b7a9213ca7655 (diff)
downloadlibpinyin-a7526ca001e88457c290547bd42315bd4bb876be.tar.gz
libpinyin-a7526ca001e88457c290547bd42315bd4bb876be.tar.xz
libpinyin-a7526ca001e88457c290547bd42315bd4bb876be.zip
declare class PhraseTableEntry
-rw-r--r--src/include/novel_types.h3
-rw-r--r--src/storage/phrase_large_table3.cpp29
2 files changed, 32 insertions, 0 deletions
diff --git a/src/include/novel_types.h b/src/include/novel_types.h
index fcb801e..2d309a1 100644
--- a/src/include/novel_types.h
+++ b/src/include/novel_types.h
@@ -125,8 +125,11 @@ const phrase_token_t token_min = 0;
const phrase_token_t token_max = UINT_MAX;
const char c_separate = '#';
+
typedef guint32 table_offset_t;
+typedef guint32 table_entry_header_t;
+
typedef double parameter_t;
/* Array of ChewingKey/ChewingKeyRest */
diff --git a/src/storage/phrase_large_table3.cpp b/src/storage/phrase_large_table3.cpp
index 12632ae..07c5e70 100644
--- a/src/storage/phrase_large_table3.cpp
+++ b/src/storage/phrase_large_table3.cpp
@@ -23,6 +23,35 @@
namespace pinyin{
+/**
+ * Data Structure:
+ * m_chunk consists of table entry header and array of tokens.
+ */
+
+class PhraseTableEntry{
+ friend class PhraseLargeTable3;
+protected:
+ MemoryChunk m_chunk;
+
+private:
+ /* Disallow used outside. */
+ PhraseTableEntry() {}
+
+public:
+ /* search method */
+ int search(/* in */ const ucs4_t phrase[], /* out */ PhraseTokens tokens) const;
+
+ /* add_index/remove_index method */
+ int add_index(/* in */ const ucs4_t phrase[], /* in */ phrase_token_t token);
+ int remove_index(/* in */ const ucs4_t phrase[], /* in */ phrase_token_t token);
+
+ /* get length method */
+ int get_length() const;
+
+ /* mask out method */
+ bool mask_out(phrase_token_t mask, phrase_token_t value);
+};
+
/* load text method */
bool PhraseLargeTable3::load_text(FILE * infile){