diff options
author | Victor Chahuneau <vchahune@cs.cmu.edu> | 2012-06-06 01:10:49 -0400 |
---|---|---|
committer | Victor Chahuneau <vchahune@cs.cmu.edu> | 2012-06-06 01:10:49 -0400 |
commit | 34c2c129a376abfc79e76cf2fa1282b89ef605b6 (patch) | |
tree | d007e4928c4ccfc93fe34eb0934667865385d1ab /python/src/hypergraph.pxd | |
parent | 98e13188c40adf13b73ca994d3410f3e87d20355 (diff) |
Python - Added hypergraph functionnality
- k-best translations
- 1-best, k-best structures
- sample derivations from the forest
- intersect hypergraph and lattice
- lattice
Diffstat (limited to 'python/src/hypergraph.pxd')
-rw-r--r-- | python/src/hypergraph.pxd | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/python/src/hypergraph.pxd b/python/src/hypergraph.pxd index 05977fa8..4aef6955 100644 --- a/python/src/hypergraph.pxd +++ b/python/src/hypergraph.pxd @@ -1,10 +1,41 @@ from libcpp.string cimport string from libcpp.vector cimport vector -from utils cimport WordID +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 string ViterbiESentence(Hypergraph hg, vector[WordID]* trans) + 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) |