mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
Improve error message when entity sequence is inconsistent
This commit is contained in:
parent
cbd2794be0
commit
99fbc7db33
|
@ -421,7 +421,12 @@ cdef class Doc:
|
|||
for i in range(self.length):
|
||||
token = &self.c[i]
|
||||
if token.ent_iob == 1:
|
||||
assert start != -1
|
||||
if start == -1:
|
||||
seq = ['%s|%s' % (t.text, t.ent_iob_) for t in self[i-5:i+5]]
|
||||
raise ValueError(
|
||||
"token.ent_iob values make invalid sequence: "
|
||||
"I without B\n"
|
||||
"{seq}".format(seq=' '.join(seq)))
|
||||
elif token.ent_iob == 2 or token.ent_iob == 0:
|
||||
if start != -1:
|
||||
output.append(Span(self, start, i, label=label))
|
||||
|
|
Loading…
Reference in New Issue
Block a user