Skip to content

Commit

Permalink
restore entities of sample in initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
svlandeg committed Mar 27, 2024
1 parent 42188b3 commit d41d875
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spacy/pipeline/entity_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,11 @@ def initialize(
nO = self.kb.entity_vector_length
doc_sample = []
vector_sample = []
orig_ents = []
for eg in islice(get_examples(), 10):
doc = eg.x
if self.use_gold_ents:
orig_ents.append(doc.ents)
ents, _ = eg.get_aligned_ents_and_ner()
doc.ents = ents
doc_sample.append(doc)
Expand All @@ -313,6 +315,10 @@ def initialize(
if not has_annotations:
# Clean up dummy annotation
doc.ents = []
if self.use_gold_ents:
assert len(doc_sample) == len(orig_ents)
for doc, orig_ent in zip(doc_sample, orig_ents):
doc.ents = orig_ent

def batch_has_learnable_example(self, examples):
"""Check if a batch contains a learnable example.
Expand Down

0 comments on commit d41d875

Please sign in to comment.