summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2010-10-19 14:48:33 +0800
committerPeng Wu <alexepico@gmail.com>2010-10-19 14:48:33 +0800
commit77f51924d4660e0a7c295dc9af6b305118214ede (patch)
tree3b14f4cb9a8afca983ac22afeade7034867fcc17 /src
parent56c5c4a737c56de8e8e4ac0a09f8c2af4f6d0a39 (diff)
downloadlibpinyin-77f51924d4660e0a7c295dc9af6b305118214ede.tar.gz
libpinyin-77f51924d4660e0a7c295dc9af6b305118214ede.tar.xz
libpinyin-77f51924d4660e0a7c295dc9af6b305118214ede.zip
begin to write phrase lookup header
Diffstat (limited to 'src')
-rw-r--r--src/lookup/lookup.h25
-rw-r--r--src/lookup/phrase_lookup.h23
-rw-r--r--src/lookup/pinyin_lookup.h29
3 files changed, 52 insertions, 25 deletions
diff --git a/src/lookup/lookup.h b/src/lookup/lookup.h
index b85101c..8832fbc 100644
--- a/src/lookup/lookup.h
+++ b/src/lookup/lookup.h
@@ -43,4 +43,29 @@ struct lookup_value_t{
}
};
+typedef GArray * MatchResults; /* Array of phrase_token_t */
+
+namespace novel{
+ class PinyinLargeTable;
+ class PhraseLargeTable;
+ class FacadePhraseIndex;
+ class Bigram;
+};
+
+/* Note:
+ * LookupStepIndex:
+ * the main purpose of lookup step index is served for an index
+ * for lookup step content, which can quickly merge the same node
+ * with different possibilities,
+ * then only keep the highest value of the node.
+ * LookupStepContent:
+ * the place to store the lookup values of current step,
+ * and indexed by lookup step index.
+ * See also comments on lookup_value_t.
+ */
+
+typedef GHashTable * LookupStepIndex;
+/* Key: lookup_key_t, Value: int m, index to m_steps_content[i][m] */
+typedef GArray * LookupStepContent; /* array of lookup_value_t */
+
#endif
diff --git a/src/lookup/phrase_lookup.h b/src/lookup/phrase_lookup.h
index 3565031..5473622 100644
--- a/src/lookup/phrase_lookup.h
+++ b/src/lookup/phrase_lookup.h
@@ -29,5 +29,28 @@
* @brief the definitions of phrase lookup related classes and structs.
*/
+class PhraseLookup{
+private:
+
+protected:
+ //saved varibles
+ novel::PhraseLargeTable * m_phrase_table;
+ novel::FacadePhraseIndex * m_phrase_index;
+ novel::Bigram * m_bigram;
+
+ //internal step data structure
+ GPtrArray * m_steps_index;
+ /* Array of LookupStepIndex */
+ GPtrArray * m_steps_content;
+ /* Array of LookupStepContent */
+
+ GArray * m_table_cache;
+ /* Array of phrase_token_t, for phrase lookup. */
+
+public:
+ bool get_best_match(int sentence_length, utf16_t sentence[], MatchResults & results);
+
+ bool convert_to_utf8(MatchResults results, /* out */ char * & result_string);
+};
#endif
diff --git a/src/lookup/pinyin_lookup.h b/src/lookup/pinyin_lookup.h
index 244d15f..c95d16d 100644
--- a/src/lookup/pinyin_lookup.h
+++ b/src/lookup/pinyin_lookup.h
@@ -62,30 +62,6 @@ struct lookup_constraint_t{
};
typedef GArray * CandidateConstraints; /* Array of lookup_constraint_t */
-typedef GArray * MatchResults; /* Array of phrase_token_t */
-
-namespace novel{
-class PinyinLargeTable;
-class FacadePhraseIndex;
-class Bigram;
-};
-
-/* Note:
- * LookupStepIndex:
- * the main purpose of lookup step index is served for an index
- * for lookup step content, which can quickly merge the same node
- * with different possibilities,
- * then only keep the highest value of the node.
- * LookupStepContent:
- * the place to store the lookup values of current step,
- * and indexed by lookup step index.
- * See also comments on lookup_value_t.
- */
-
-typedef GHashTable * LookupStepIndex;
-/* Key: lookup_key_t, Value: int m, index to m_steps_content[i][m] */
-typedef GArray * LookupStepContent; /* array of lookup_value_t */
-
/* Note:
* winner tree for beam search.
@@ -121,7 +97,10 @@ protected:
/* Array of LookupStepContent */
GArray * m_table_cache;
- /* Array of PhraseIndexRanges */
+ /* Array of PhraseIndexRanges,
+ * PhraseIndexRanges is an array of GArray of PhraseIndexRange,
+ * indexed by phrase library (only contains enabled phrase libraries).
+ */
WinnerTree * m_winner_tree;