summaryrefslogtreecommitdiff
path: root/python/src/hypergraph.pxd
diff options
context:
space:
mode:
authorPatrick Simianer <simianer@cl.uni-heidelberg.de>2012-06-13 14:42:07 +0200
committerPatrick Simianer <simianer@cl.uni-heidelberg.de>2012-06-13 14:42:07 +0200
commite6d3c25191873ca0cf99db8e89702ed91d65277c (patch)
treeb0697ece6f5e4a8229915758c68750793a23f776 /python/src/hypergraph.pxd
parent62c805c90c5347b844f92574e240db5c65578e12 (diff)
parent3acdf1e4b37637d6df86a7b54fb0f1b0464c172b (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'python/src/hypergraph.pxd')
-rw-r--r--python/src/hypergraph.pxd41
1 files changed, 41 insertions, 0 deletions
diff --git a/python/src/hypergraph.pxd b/python/src/hypergraph.pxd
new file mode 100644
index 00000000..4aef6955
--- /dev/null
+++ b/python/src/hypergraph.pxd
@@ -0,0 +1,41 @@
+from libcpp.string cimport string
+from libcpp.vector cimport vector
+from utils cimport *
+cimport lattice
+
+cdef extern from "decoder/hg.h":
+ cdef cppclass Hypergraph:
+ cppclass Node:
+ int id_
+ WordID cat_
+ WordID NT()
+ #EdgesVector in_edges_
+ #EdgesVector out_edges_
+ Hypergraph(Hypergraph)
+ vector[Node] nodes_
+
+cdef extern from "decoder/viterbi.h":
+ cdef prob_t ViterbiESentence(Hypergraph hg, vector[WordID]* trans)
+ cdef string ViterbiETree(Hypergraph hg)
+
+cdef extern from "decoder/hg_io.h" namespace "HypergraphIO":
+ bint ReadFromJSON(istream* inp, Hypergraph* out)
+ bint WriteToJSON(Hypergraph hg, bint remove_rules, ostream* out)
+
+ #void WriteAsCFG(Hypergraph hg)
+ #void WriteTarget(string base, unsigned sent_id, Hypergraph hg)
+
+ void ReadFromPLF(string inp, Hypergraph* out, int line=*)
+ string AsPLF(Hypergraph hg, bint include_global_parentheses=*)
+ string AsPLF(lattice.Lattice lat, bint include_global_parentheses=*)
+ void PLFtoLattice(string plf, lattice.Lattice* pl)
+
+cdef extern from "decoder/hg_intersect.h" namespace "HG":
+ bint Intersect(lattice.Lattice target, Hypergraph* hg)
+
+cdef extern from "decoder/hg_sampler.h" namespace "HypergraphSampler":
+ cdef cppclass Hypothesis:
+ vector[WordID] words
+ SparseVector[double] fmap
+ prob_t model_score
+ void sample_hypotheses(Hypergraph hg, unsigned n, MT19937* rng, vector[Hypothesis]* hypos)