From 7bafc789e780164f15cc50fe11627c4503bd9151 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 8 Aug 2015 23:32:42 +0200 Subject: [PATCH] * Add stack and queue properties to stateclass, for python access --- spacy/syntax/stateclass.pyx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spacy/syntax/stateclass.pyx b/spacy/syntax/stateclass.pyx index 2a7bcfd7a..d5d86594e 100644 --- a/spacy/syntax/stateclass.pyx +++ b/spacy/syntax/stateclass.pyx @@ -36,6 +36,14 @@ cdef class StateClass: self._buffer[i] = i self._empty_token.lex = &EMPTY_LEXEME + @property + def stack(self): + return {self.S(i) for i in range(self._s_i)} + + @property + def queue(self): + return {self.B(i) for i in range(self._b_i, self.length)} + cdef int E(self, int i) nogil: if self._e_i <= 0 or self._e_i >= self.length: return 0