diff options
Diffstat (limited to 'python/cdec/grammar.pxd')
-rw-r--r-- | python/cdec/grammar.pxd | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/python/cdec/grammar.pxd b/python/cdec/grammar.pxd new file mode 100644 index 00000000..0ffe80fa --- /dev/null +++ b/python/cdec/grammar.pxd @@ -0,0 +1,43 @@ +from libcpp.vector cimport vector +from libcpp.string cimport string +from utils cimport * + +cdef extern from "decoder/trule.h": + cdef cppclass AlignmentPoint: + AlignmentPoint(int s, int t) + AlignmentPoint Inverted() + short s_ + short t_ + + cdef cppclass TRule: + vector[WordID] f_ + vector[WordID] e_ + vector[AlignmentPoint] a_ + FastSparseVector[weight_t] scores_ + WordID lhs_ + int arity_ + bint IsUnary() + bint IsGoal() + void ComputeArity() + +cdef extern from "decoder/grammar.h": + cdef cppclass RuleBin: + int GetNumRules() + shared_ptr[TRule] GetIthRule(int i) + int Arity() + + ctypedef RuleBin const_RuleBin "const RuleBin" + + cdef cppclass GrammarIter: + const_RuleBin* GetRules() + + ctypedef GrammarIter const_GrammarIter "const GrammarIter" + + cdef cppclass Grammar: + const_GrammarIter* GetRoot() + string GetGrammarName() + void SetGrammarName(string) + + cdef cppclass TextGrammar(Grammar): + TextGrammar() + void AddRule(shared_ptr[TRule]& rule) nogil |