mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-24 00:46:28 +03:00
Allow entities to be set by Span, or by 4-tuple (with entity ID)
This commit is contained in:
parent
60fdf4d5f1
commit
15e42a1ba9
|
@ -240,7 +240,16 @@ cdef class Doc:
|
|||
self.c[i].ent_iob = 0
|
||||
cdef attr_t ent_type
|
||||
cdef int start, end
|
||||
for ent_type, start, end in ents:
|
||||
for ent_info in ents:
|
||||
if isinstance(ent_info, Span):
|
||||
ent_id = ent_info.ent_id
|
||||
ent_type = ent_info.label
|
||||
start = ent_info.start
|
||||
end = ent_info.end
|
||||
elif len(ent_info) == 3:
|
||||
ent_type, start, end = ent_info
|
||||
else:
|
||||
ent_id, ent_type, start, end = ent_info
|
||||
if ent_type is None or ent_type < 0:
|
||||
# Mark as O
|
||||
for i in range(start, end):
|
||||
|
@ -254,7 +263,6 @@ cdef class Doc:
|
|||
# Set start as B
|
||||
self.c[start].ent_iob = 3
|
||||
|
||||
|
||||
@property
|
||||
def noun_chunks(self):
|
||||
"""Yield spans for base noun phrases."""
|
||||
|
|
Loading…
Reference in New Issue
Block a user