mirror of https://github.com/explosion/spaCy.git
Fix Issue #587: Segfault in Matcher, due to simple error in the state machine.
This commit is contained in:
parent
7e5f63a595
commit
d563f1eadb
|
@ -1,4 +1,5 @@
|
||||||
# cython: profile=True
|
# cython: profile=True
|
||||||
|
# cython: infer_types=True
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from os import path
|
from os import path
|
||||||
|
@ -277,6 +278,8 @@ cdef class Matcher:
|
||||||
# we over-write them (q doesn't advance)
|
# we over-write them (q doesn't advance)
|
||||||
for state in partials:
|
for state in partials:
|
||||||
action = get_action(state.second, token)
|
action = get_action(state.second, token)
|
||||||
|
if action == PANIC:
|
||||||
|
raise Exception("Error selecting action in matcher")
|
||||||
while action == ADVANCE_ZERO:
|
while action == ADVANCE_ZERO:
|
||||||
state.second += 1
|
state.second += 1
|
||||||
action = get_action(state.second, token)
|
action = get_action(state.second, token)
|
||||||
|
@ -288,6 +291,7 @@ cdef class Matcher:
|
||||||
elif action == REJECT:
|
elif action == REJECT:
|
||||||
pass
|
pass
|
||||||
elif action == ADVANCE:
|
elif action == ADVANCE:
|
||||||
|
partials[q] = state
|
||||||
partials[q].second += 1
|
partials[q].second += 1
|
||||||
q += 1
|
q += 1
|
||||||
elif action == ACCEPT:
|
elif action == ACCEPT:
|
||||||
|
@ -307,6 +311,8 @@ cdef class Matcher:
|
||||||
# Check whether we open any new patterns on this token
|
# Check whether we open any new patterns on this token
|
||||||
for pattern in self.patterns:
|
for pattern in self.patterns:
|
||||||
action = get_action(pattern, token)
|
action = get_action(pattern, token)
|
||||||
|
if action == PANIC:
|
||||||
|
raise Exception("Error selecting action in matcher")
|
||||||
while action == ADVANCE_ZERO:
|
while action == ADVANCE_ZERO:
|
||||||
pattern += 1
|
pattern += 1
|
||||||
action = get_action(pattern, token)
|
action = get_action(pattern, token)
|
||||||
|
|
Loading…
Reference in New Issue