mirror of
https://github.com/explosion/spaCy.git
synced 2025-02-06 06:30:35 +03:00
Debugging
This commit is contained in:
parent
e9860daf4b
commit
6e4d486b1e
|
@ -262,6 +262,9 @@ cdef class Parser:
|
||||||
free(is_valid)
|
free(is_valid)
|
||||||
|
|
||||||
def update(self, examples, drop=0., set_annotations=False, sgd=None, losses=None):
|
def update(self, examples, drop=0., set_annotations=False, sgd=None, losses=None):
|
||||||
|
# TODO: This is just here for debugging, remove later.
|
||||||
|
for eg in examples:
|
||||||
|
oracle_seq = self.moves.get_oracle_sequence(eg)
|
||||||
if losses is None:
|
if losses is None:
|
||||||
losses = {}
|
losses = {}
|
||||||
losses.setdefault(self.name, 0.)
|
losses.setdefault(self.name, 0.)
|
||||||
|
|
|
@ -73,15 +73,39 @@ cdef class TransitionSystem:
|
||||||
state = states[0]
|
state = states[0]
|
||||||
gold = golds[0]
|
gold = golds[0]
|
||||||
history = []
|
history = []
|
||||||
|
debug_log = []
|
||||||
while not state.is_final():
|
while not state.is_final():
|
||||||
self.set_costs(is_valid, costs, state, gold)
|
self.set_costs(is_valid, costs, state, gold)
|
||||||
for i in range(self.n_moves):
|
for i in range(self.n_moves):
|
||||||
if is_valid[i] and costs[i] <= 0:
|
if is_valid[i] and costs[i] <= 0:
|
||||||
action = self.c[i]
|
action = self.c[i]
|
||||||
history.append(i)
|
history.append(i)
|
||||||
|
s0 = state.S(0)
|
||||||
|
b0 = state.B(0)
|
||||||
|
debug_log.append(" ".join((
|
||||||
|
self.get_class_name(i),
|
||||||
|
"S0=", (example.x[s0].text if s0 >= 0 else "__"),
|
||||||
|
"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")
|
||||||
|
for i in range(self.n_moves):
|
||||||
|
print(self.get_class_name(i))
|
||||||
|
print("Gold")
|
||||||
|
for token in example.y:
|
||||||
|
print(token.text, token.dep_, token.head.text)
|
||||||
|
s0 = state.S(0)
|
||||||
|
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 head?", str(state.has_head(state.S(0))),
|
||||||
|
)))
|
||||||
|
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