From 9c69c3c3134c6ab03708b7e23db38548f67a5f19 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Fri, 21 Oct 2022 13:14:03 +0200 Subject: [PATCH] Harmonize checks for entity candidate generation and document skipping. --- spacy/pipeline/entity_linker.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spacy/pipeline/entity_linker.py b/spacy/pipeline/entity_linker.py index 439c3af59..c3a0a3815 100644 --- a/spacy/pipeline/entity_linker.py +++ b/spacy/pipeline/entity_linker.py @@ -476,7 +476,7 @@ class EntityLinker(TrainablePipe): ( [doc.ents[idx] for idx in next(valid_ent_idx_per_doc)] for doc in docs - if len(doc.ents) + if len(docs) and len(doc.ents) ), ) else: @@ -487,11 +487,11 @@ class EntityLinker(TrainablePipe): for idx in next(valid_ent_idx_per_doc) ] for doc in docs - if len(doc.ents) + if len(docs) and len(doc.ents) ) for doc_idx, doc in enumerate(docs): - if len(doc) == 0: + if len(doc) == 0 or len(doc.ents) == 0: continue sentences = [s for s in doc.sents] doc_ent_cands = list(next(all_ent_cands)) if len(doc.ents) else []