mirror of
https://github.com/explosion/spaCy.git
synced 2025-02-05 22:20:34 +03:00
Clean up debugging
This commit is contained in:
parent
b250f6b62f
commit
e92be79ffc
|
@ -61,7 +61,7 @@ cdef class TransitionSystem:
|
||||||
offset += len(doc)
|
offset += len(doc)
|
||||||
return states
|
return states
|
||||||
|
|
||||||
def get_oracle_sequence(self, Example example):
|
def get_oracle_sequence(self, Example example, _debug=False):
|
||||||
cdef Pool mem = Pool()
|
cdef Pool mem = Pool()
|
||||||
# n_moves should not be zero at this point, but make sure to avoid zero-length mem alloc
|
# n_moves should not be zero at this point, but make sure to avoid zero-length mem alloc
|
||||||
assert self.n_moves > 0
|
assert self.n_moves > 0
|
||||||
|
@ -70,6 +70,8 @@ cdef class TransitionSystem:
|
||||||
|
|
||||||
cdef StateClass state
|
cdef StateClass state
|
||||||
states, golds, n_steps = self.init_gold_batch([example])
|
states, golds, n_steps = self.init_gold_batch([example])
|
||||||
|
if not states:
|
||||||
|
return []
|
||||||
state = states[0]
|
state = states[0]
|
||||||
gold = golds[0]
|
gold = golds[0]
|
||||||
history = []
|
history = []
|
||||||
|
@ -82,30 +84,32 @@ cdef class TransitionSystem:
|
||||||
history.append(i)
|
history.append(i)
|
||||||
s0 = state.S(0)
|
s0 = state.S(0)
|
||||||
b0 = state.B(0)
|
b0 = state.B(0)
|
||||||
debug_log.append(" ".join((
|
if _debug:
|
||||||
self.get_class_name(i),
|
debug_log.append(" ".join((
|
||||||
"S0=", (example.x[s0].text if s0 >= 0 else "__"),
|
self.get_class_name(i),
|
||||||
"B0=", (example.x[b0].text if b0 >= 0 else "__"),
|
"S0=", (example.x[s0].text if s0 >= 0 else "__"),
|
||||||
"S0 head?", str(state.has_head(state.S(0))),
|
"B0=", (example.x[b0].text if b0 >= 0 else "__"),
|
||||||
)))
|
"S0 head?", str(state.has_head(state.S(0))),
|
||||||
|
)))
|
||||||
action.do(state.c, action.label)
|
action.do(state.c, action.label)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print("Actions")
|
if _debug:
|
||||||
for i in range(self.n_moves):
|
print("Actions")
|
||||||
print(self.get_class_name(i))
|
for i in range(self.n_moves):
|
||||||
print("Gold")
|
print(self.get_class_name(i))
|
||||||
for token in example.y:
|
print("Gold")
|
||||||
print(token.text, token.dep_, token.head.text)
|
for token in example.y:
|
||||||
s0 = state.S(0)
|
print(token.text, token.dep_, token.head.text)
|
||||||
b0 = state.B(0)
|
s0 = state.S(0)
|
||||||
debug_log.append(" ".join((
|
b0 = state.B(0)
|
||||||
"?",
|
debug_log.append(" ".join((
|
||||||
"S0=", (example.x[s0].text if s0 >= 0 else "-"),
|
"?",
|
||||||
"B0=", (example.x[b0].text if b0 >= 0 else "-"),
|
"S0=", (example.x[s0].text if s0 >= 0 else "-"),
|
||||||
"S0 head?", str(state.has_head(state.S(0))),
|
"B0=", (example.x[b0].text if b0 >= 0 else "-"),
|
||||||
)))
|
"S0 head?", str(state.has_head(state.S(0))),
|
||||||
print("\n".join(debug_log))
|
)))
|
||||||
|
print("\n".join(debug_log))
|
||||||
raise ValueError(Errors.E024)
|
raise ValueError(Errors.E024)
|
||||||
return history
|
return history
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user