Skip to content

Commit 73d07e9

Browse files
shepdldaveshepardsvlandeg
authored
Fix issue #241: Wrong datatype in error message (#242)
* Fix issue #241: Wrong datatype in error message Correct assertion error when CoNLL parser fails and expand error message. * Update neuralcoref/train/conllparser.py * Update neuralcoref/train/conllparser.py * Update neuralcoref/train/conllparser.py Co-authored-by: Dave Shepard (CDH) <dave@humnet.ucla.edu> Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
1 parent ace367a commit 73d07e9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

neuralcoref/train/conllparser.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,11 @@ def add_conll_utterance(
348348
# Convert conll tokens coref index in spacy tokens indexes
349349
identified_gold = [False] * len(corefs)
350350
for coref in corefs:
351-
assert (
352-
coref["label"] is not None
353-
and coref["start"] is not None
354-
and coref["end"] is not None
355-
), ("Error in coreference " + coref + " in " + parsed)
351+
missing_values = [key for key in ['label', 'start', 'end', ] if coref.get(key, None) is None]
352+
if missing_values:
353+
found_values = {key: coref[key] for key in ['label', 'start', 'end'] if coref.get(key, None) is not None}
354+
raise Exception(f"Coref {self.name} with fields {found_values} has empty values for the keys {missing_values}.")
355+
356356
coref["start"] = conll_lookup[coref["start"]][0]
357357
coref["end"] = conll_lookup[coref["end"]][-1]
358358

0 commit comments

Comments
 (0)