Fix GoldParse class when no entities

This commit is contained in:
Matthew Honnibal 2018-09-27 15:14:27 +02:00
parent c8a2841308
commit b9ef8ac616
1 changed files with 3 additions and 4 deletions

View File

@ -431,19 +431,18 @@ cdef class GoldParse:
if tags is None: if tags is None:
tags = [None for _ in words] tags = [None for _ in words]
if heads is None: if heads is None:
heads = [None for token in words] heads = [None for _ in words]
if deps is None: if deps is None:
deps = [None for _ in words] deps = [None for _ in words]
if entities is None:
entities = [None for _ in words]
if morphology is None: if morphology is None:
morphology = [None for _ in words] morphology = [None for _ in words]
if entities is None:
entities = [None for _ in words]
elif len(entities) == 0: elif len(entities) == 0:
entities = ['O' for _ in words] entities = ['O' for _ in words]
elif not isinstance(entities[0], basestring): elif not isinstance(entities[0], basestring):
# Assume we have entities specified by character offset. # Assume we have entities specified by character offset.
entities = biluo_tags_from_offsets(doc, entities) entities = biluo_tags_from_offsets(doc, entities)
self.mem = Pool() self.mem = Pool()
self.loss = 0 self.loss = 0
self.length = len(doc) self.length = len(doc)