summaryrefslogtreecommitdiff
path: root/python/src/sa/sym.pxi
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-07-28 12:11:44 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2012-07-28 12:11:44 -0400
commit9052682200365b64115f2f88eb02cb150dc7ade4 (patch)
tree8e9609daeaa93f0edf421114c5cdbed016709332 /python/src/sa/sym.pxi
parent5276e368ad643434fd73527329ed70507ee49dfc (diff)
parent455ca8bc1406ec2f6554fce9be7488bb3cca75dd (diff)
Merge branch 'master' of github.com:redpony/cdec
Diffstat (limited to 'python/src/sa/sym.pxi')
-rw-r--r--python/src/sa/sym.pxi16
1 files changed, 10 insertions, 6 deletions
diff --git a/python/src/sa/sym.pxi b/python/src/sa/sym.pxi
index 3fd6c5a7..132925f6 100644
--- a/python/src/sa/sym.pxi
+++ b/python/src/sa/sym.pxi
@@ -53,14 +53,12 @@ cdef class Alphabet:
if self.isvar(sym):
if sym in self.id2sym:
return self.id2sym[sym]
-
ind = self.getindex(sym)
if ind > 0:
self.id2sym[sym] = "[%s,%d]" % (self.tocat(sym), ind)
else:
self.id2sym[sym] = "[%s]" % self.tocat(sym)
return self.id2sym[sym]
-
else:
return self.terminals.word(sym)
@@ -88,14 +86,20 @@ cdef class Alphabet:
cdef Alphabet ALPHABET = Alphabet()
-def sym_tostring(int sym):
+cdef char* sym_tostring(int sym):
return ALPHABET.tostring(sym)
-def sym_fromstring(bytes string, bint terminal):
- return ALPHABET.fromstring(string, terminal)
+cdef char* sym_tocat(int sym):
+ return ALPHABET.tocat(sym)
-def sym_isvar(int sym):
+cdef int sym_isvar(int sym):
return ALPHABET.isvar(sym)
+cdef int sym_getindex(int sym):
+ return ALPHABET.getindex(sym)
+
cdef int sym_setindex(int sym, int id):
return ALPHABET.setindex(sym, id)
+
+def sym_fromstring(char* string, bint terminal):
+ return ALPHABET.fromstring(string, terminal)