remove redundant code from master in EntityLinker

This commit is contained in:
svlandeg 2020-06-20 23:07:42 +02:00
parent 6179774278
commit 12dc8ab208
2 changed files with 3 additions and 12 deletions

View File

@ -1136,14 +1136,6 @@ class EntityLinker(Pipe):
# how many neightbour sentences to take into account
self.n_sents = cfg.get("n_sents", 0)
def set_kb(self, kb):
self.kb = kb
def require_model(self):
# Raise an error if the component's model is not initialized.
if getattr(self, "model", None) in (None, True, False):
raise ValueError(Errors.E109.format(name=self.name))
def require_kb(self):
# Raise an error if the knowledge base is not initialized.
if len(self.kb) == 0:

View File

@ -70,14 +70,13 @@ def tagger():
def entity_linker():
nlp = Language()
nlp.add_pipe(nlp.create_pipe("entity_linker"))
kb = KnowledgeBase(nlp.vocab, entity_vector_length=1)
kb.add_entity("test", 0.0, zeros((1, 1), dtype="f"))
nlp.add_pipe(nlp.create_pipe("entity_linker", {"kb": kb}))
entity_linker = nlp.get_pipe("entity_linker")
# need to add model for two reasons:
# 1. no model leads to error in serialization,
# 2. the affected line is the one for model serialization
kb = KnowledgeBase(nlp.vocab, entity_vector_length=1)
kb.add_entity("test", 0.0, zeros((1, 1), dtype="f"))
entity_linker.set_kb(kb)
entity_linker.begin_training(pipeline=nlp.pipeline)
return entity_linker