* Catch oracle errors

This commit is contained in:
Matthew Honnibal 2015-02-02 23:02:04 +11:00
parent de772088e6
commit c55a33d045
1 changed files with 8 additions and 7 deletions

View File

@ -26,6 +26,7 @@ from thinc.learner cimport LinearModel
from ..tokens cimport Tokens, TokenC from ..tokens cimport Tokens, TokenC
from .arc_eager cimport TransitionSystem, Transition from .arc_eager cimport TransitionSystem, Transition
from .arc_eager import OracleError
from ._state cimport init_state, State, is_final, get_idx, get_s0, get_s1, get_n0, get_n1 from ._state cimport init_state, State, is_final, get_idx, get_s0, get_s1, get_n0, get_n1
@ -131,11 +132,11 @@ cdef class GreedyParser:
if gold_heads[i] != -1: if gold_heads[i] != -1:
n_corr += (i + state.sent[i].head) == gold_heads[i] n_corr += (i + state.sent[i].head) == gold_heads[i]
if force_gold and n_corr != tokens.length: if force_gold and n_corr != tokens.length:
print py_words #print py_words
print gold_heads #print gold_heads
for move, state_str in history: #for move, state_str in history:
print move, state_str # print move, state_str
for i in range(tokens.length): #for i in range(tokens.length):
print py_words[i], py_words[i + state.sent[i].head], py_words[gold_heads[i]] # print py_words[i], py_words[i + state.sent[i].head], py_words[gold_heads[i]]
raise Exception raise OracleError
return n_corr return n_corr