mirror of https://github.com/explosion/spaCy.git
* Wrap self.parse in nogil, and break if an invalid move is predicted. The invalid break is a work-around that papers over likely bugs, but we can't easily break in the nogil block, and otherwise we'll get an infinite loop. Need to set this as an error flag.
This commit is contained in:
parent
fd1eeb3102
commit
5edac11225
|
@ -84,7 +84,6 @@ cdef class Parser:
|
||||||
|
|
||||||
cdef Example eg = Example(self.model.n_classes, CONTEXT_SIZE,
|
cdef Example eg = Example(self.model.n_classes, CONTEXT_SIZE,
|
||||||
self.model.n_feats, self.model.n_feats)
|
self.model.n_feats, self.model.n_feats)
|
||||||
with nogil:
|
|
||||||
self.parse(stcls, eg.c)
|
self.parse(stcls, eg.c)
|
||||||
tokens.set_parse(stcls._sent)
|
tokens.set_parse(stcls._sent)
|
||||||
|
|
||||||
|
@ -98,6 +97,8 @@ cdef class Parser:
|
||||||
cdef void parse(self, StateClass stcls, ExampleC eg) nogil:
|
cdef void parse(self, StateClass stcls, ExampleC eg) nogil:
|
||||||
while not stcls.is_final():
|
while not stcls.is_final():
|
||||||
self.predict(stcls, &eg)
|
self.predict(stcls, &eg)
|
||||||
|
if not eg.is_valid[eg.guess]:
|
||||||
|
break
|
||||||
self.moves.c[eg.guess].do(stcls, self.moves.c[eg.guess].label)
|
self.moves.c[eg.guess].do(stcls, self.moves.c[eg.guess].label)
|
||||||
self.moves.finalize_state(stcls)
|
self.moves.finalize_state(stcls)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue