diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2012-07-28 12:11:44 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2012-07-28 12:11:44 -0400 |
commit | 306e0ba4754c6c4f460536cfe8c3f118dc1cc175 (patch) | |
tree | ad5ea3b0a5370ac613d1bad715fe0f5ab8c91c11 /python/src/sa/sym.pxi | |
parent | 934e55dc12c3f374684bc6a0797e6f85c7abb85a (diff) | |
parent | ee5e376e263d9aeabdeee6968b4457f53d3fc772 (diff) |
Merge branch 'master' of github.com:redpony/cdec
Diffstat (limited to 'python/src/sa/sym.pxi')
-rw-r--r-- | python/src/sa/sym.pxi | 16 |
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) |