summaryrefslogtreecommitdiff
path: root/python/src/grammar.pxd
diff options
context:
space:
mode:
authorVictor Chahuneau <vchahune@cs.cmu.edu>2012-07-21 01:22:53 -0400
committerVictor Chahuneau <vchahune@cs.cmu.edu>2012-07-21 01:22:53 -0400
commit06f90d83a1feafad301d365a4a437e44f68be45b (patch)
tree24128de1cb5a4767151f9380c46104a26121535d /python/src/grammar.pxd
parentc4c9c2febd5af552ecddc215758e32b88013fbc7 (diff)
[python] Support for grammars
- Translation rules can now be create programatically - Grammars = list of translation rules can be used for translation - Feature expectations on the hypergraph (inside_outside)
Diffstat (limited to 'python/src/grammar.pxd')
-rw-r--r--python/src/grammar.pxd43
1 files changed, 43 insertions, 0 deletions
diff --git a/python/src/grammar.pxd b/python/src/grammar.pxd
new file mode 100644
index 00000000..43806f71
--- /dev/null
+++ b/python/src/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 "const RuleBin":
+ int GetNumRules()
+ shared_ptr[TRule] GetIthRule(int i)
+ int Arity()
+
+ cdef cppclass GrammarIter "const GrammarIter":
+ RuleBin* GetRules()
+ GrammarIter* Extend(int symbol)
+
+ cdef cppclass Grammar:
+ GrammarIter* GetRoot()
+ bint HasRuleForSpan(int i, int j, int distance)
+ unsigned GetCTFLevels()
+ string GetGrammarName()
+ void SetGrammarName(string)
+
+ cdef cppclass TextGrammar(Grammar):
+ TextGrammar()
+ void AddRule(shared_ptr[TRule]& rule)