From db5a43318c50122e2a0481e515d3c4a5fdfc48b9 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 27 Mar 2015 17:29:58 +0100 Subject: [PATCH] * Improve print_state debug printer --- spacy/syntax/parser.pyx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spacy/syntax/parser.pyx b/spacy/syntax/parser.pyx index 02231e271..ab9de48b8 100644 --- a/spacy/syntax/parser.pyx +++ b/spacy/syntax/parser.pyx @@ -47,8 +47,8 @@ cdef unicode print_state(State* s, list words): top = words[s.stack[0]] + '_%d' % s.sent[s.stack[0]].head second = words[s.stack[-1]] + '_%d' % s.sent[s.stack[-1]].head third = words[s.stack[-2]] + '_%d' % s.sent[s.stack[-2]].head - n0 = words[s.i] - n1 = words[s.i + 1] + n0 = words[s.i] if s.i < len(words) else 'EOL' + n1 = words[s.i + 1] if s.i+1 < len(words) else 'EOL' if s.ents_len: ent = '%s %d-%d' % (s.ent.label, s.ent.start, s.ent.end) else: @@ -89,6 +89,8 @@ cdef class GreedyParser: fill_context(context, state) scores = self.model.score(context) guess = self.moves.best_valid(scores, state) + #print self.moves.move_name(guess.move, guess.label), + #print print_state(state, [w.orth_ for w in tokens]) guess.do(&guess, state) tokens.set_parse(state.sent) return 0