mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-14 13:47:13 +03:00
Remove state hashing
This commit is contained in:
parent
2512ea9eeb
commit
855872f872
|
@ -81,10 +81,7 @@ cdef class ParserBeam(object):
|
||||||
self._set_scores(beam, scores[i])
|
self._set_scores(beam, scores[i])
|
||||||
if self.golds is not None:
|
if self.golds is not None:
|
||||||
self._set_costs(beam, self.golds[i], follow_gold=follow_gold)
|
self._set_costs(beam, self.golds[i], follow_gold=follow_gold)
|
||||||
if follow_gold:
|
beam.advance(_transition_state, NULL, <void*>self.moves.c)
|
||||||
beam.advance(_transition_state, _hash_state, <void*>self.moves.c)
|
|
||||||
else:
|
|
||||||
beam.advance(_transition_state, _hash_state, <void*>self.moves.c)
|
|
||||||
beam.check_done(_check_final_state, NULL)
|
beam.check_done(_check_final_state, NULL)
|
||||||
# This handles the non-monotonic stuff for the parser.
|
# This handles the non-monotonic stuff for the parser.
|
||||||
if beam.is_done and self.golds is not None:
|
if beam.is_done and self.golds is not None:
|
||||||
|
|
|
@ -526,7 +526,7 @@ cdef class Parser:
|
||||||
for k in range(nr_class):
|
for k in range(nr_class):
|
||||||
beam.scores[i][k] = c_scores[j * scores.shape[1] + k]
|
beam.scores[i][k] = c_scores[j * scores.shape[1] + k]
|
||||||
j += 1
|
j += 1
|
||||||
beam.advance(_transition_state, _hash_state, <void*>self.moves.c)
|
beam.advance(_transition_state, NULL, <void*>self.moves.c)
|
||||||
beam.check_done(_check_final_state, NULL)
|
beam.check_done(_check_final_state, NULL)
|
||||||
beams.append(beam)
|
beams.append(beam)
|
||||||
tokvecs = self.model[0].ops.unflatten(tokvecs,
|
tokvecs = self.model[0].ops.unflatten(tokvecs,
|
||||||
|
@ -998,16 +998,16 @@ def _cleanup(Beam beam):
|
||||||
state = <StateC*>addr
|
state = <StateC*>addr
|
||||||
del state
|
del state
|
||||||
seen.add(addr)
|
seen.add(addr)
|
||||||
|
else:
|
||||||
|
print(i, addr)
|
||||||
|
print(seen)
|
||||||
|
raise Exception
|
||||||
addr = <size_t>beam._states[i].content
|
addr = <size_t>beam._states[i].content
|
||||||
if addr not in seen:
|
if addr not in seen:
|
||||||
state = <StateC*>addr
|
state = <StateC*>addr
|
||||||
del state
|
del state
|
||||||
seen.add(addr)
|
seen.add(addr)
|
||||||
|
|
||||||
|
|
||||||
cdef hash_t _hash_state(void* _state, void* _) except 0:
|
|
||||||
state = <StateC*>_state
|
|
||||||
if state.is_final():
|
|
||||||
return 1
|
|
||||||
else:
|
else:
|
||||||
return state.hash()
|
print(i, addr)
|
||||||
|
print(seen)
|
||||||
|
raise Exception
|
||||||
|
|
Loading…
Reference in New Issue
Block a user