From 0a0de85409e796d37b3b74796e2475c37d131c1b Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Thu, 23 Jan 2020 22:00:24 +0100 Subject: [PATCH] Fix gold training (#4938) * label in span not writable anymore * Revert "label in span not writable anymore" This reverts commit ab442338c8c4ddd7dfbc15348f999b74f4928090. * ensure doc is not None --- spacy/gold.pyx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/spacy/gold.pyx b/spacy/gold.pyx index 10b8bf0cf..0dfa32c84 100644 --- a/spacy/gold.pyx +++ b/spacy/gold.pyx @@ -326,14 +326,18 @@ class GoldCorpus(object): @classmethod def _make_golds(cls, examples, vocab=None, make_projective=False, ignore_misaligned=False): + filtered_examples = [] for example in examples: gold_parses = example.get_gold_parses(vocab=vocab, make_projective=make_projective, ignore_misaligned=ignore_misaligned) assert len(gold_parses) == 1 - assert gold_parses[0][0] == example.doc - example.goldparse = gold_parses[0][1] - return examples + doc, gold = gold_parses[0] + if doc: + assert doc == example.doc + example.goldparse = gold + filtered_examples.append(example) + return filtered_examples def make_orth_variants(nlp, example, orth_variant_level=0.0):