From cc18f3f23ce5568ce66834a1de3ea3abfe5c927b Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Thu, 28 Jan 2021 13:11:20 +1100 Subject: [PATCH] Improve Example error handling for NER data (#6835) * Improve Example error handling for NER data * Fix conditional --- spacy/training/example.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spacy/training/example.pyx b/spacy/training/example.pyx index bbe59e9f4..dc1c74e8a 100644 --- a/spacy/training/example.pyx +++ b/spacy/training/example.pyx @@ -356,7 +356,9 @@ def _add_entities_to_doc(doc, ner_data): return elif ner_data == []: doc.ents = [] - elif isinstance(ner_data[0], tuple): + elif not isinstance(ner_data, (list, tuple)): + raise ValueError(Errors.E973) + elif isinstance(ner_data[0], (list, tuple)): return _add_entities_to_doc( doc, offsets_to_biluo_tags(doc, ner_data)