allenai / allenai/SciREX

KeyError in Predicting End-to-End relations file

Offen
#17 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
141
Forks
33
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I'm running the prediction script and I'm getting a "metadata" KeyError as shown below

```
Traceback (most recent call last):
File "scirex/predictors/predict_n_ary_relations.py", line 109, in
predict(argv[1], argv[2], argv[3], argv[4], int(argv[5]))
File "scirex/predictors/predict_n_ary_relations.py", line 77, in predict
output_res = model.decode_relations(batch)
File ".../SciREX/scirex/models/scirex_model.py", line 385, in decode_relations
res["n_ary_relation"] = self._cluster_n_ary_relation.decode(output_n_ary_relation)
File ".../SciREX/scirex/models/relations/entity_relation.py", line 211, in decode
"metadata" : output_dict['metadata']
KeyError: 'metadata'
```

I went up to the `decode` function in `entity_relation.py`, where I replaced `output_dict['metadata'] ` with `output_dict.get('metadata',[])` For the batches that do not have any spans.

That led to this error occuring:
```
Traceback (most recent call last):
File "scirex/predictors/predict_n_ary_relations.py", line 109, in
predict(argv[1], argv[2], argv[3], argv[4], int(argv[5]))
File "scirex/predictors/predict_n_ary_relations.py", line 82, in predict
metadata = output_res['n_ary_relation']['metadata'][0]
IndexError: list index out of range
```
Returning a default value of `[]` did not seem to do the trick. How can I fix it?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.