allenai / SciREX

Data/Code Repository for https://api.semanticscholar.org/CorpusID:218470122
Apache License 2.0
129 stars 30 forks source link

KeyError "ner" when I predict on new dataset #20

Closed muguruzawang closed 3 years ago

muguruzawang commented 3 years ago

I use the model to predict named entities for new dataset but encounters the following problem: Traceback (most recent call last): File "scirex/predictors/predict_ner.py", line 123, in main() File "scirex/predictors/predict_ner.py", line 119, in main predict(archive_folder, test_file, output_file, cuda_device) File "scirex/predictors/predict_ner.py", line 35, in predict instances = dataset_reader.read(test_file) File "/home/jttang/.conda/envs/scirex_wpc/lib/python3.7/site-packages/allennlp/data/dataset_readers/dataset_reader.py", line 134, in read instances = [instance for instance in Tqdm.tqdm(instances)] File "/home/jttang/.conda/envs/scirex_wpc/lib/python3.7/site-packages/allennlp/data/dataset_readers/dataset_reader.py", line 134, in instances = [instance for instance in Tqdm.tqdm(instances)] File "/home/jttang/.conda/envs/scirex_wpc/lib/python3.7/site-packages/tqdm/_tqdm.py", line 1005, in iter for obj in iterable: File "/dat01/jttang/wpc/information_extraction/SciREX/SciREX/scirex/data/dataset_readers/scirex_full_reader.py", line 148, in _read json_dict = clean_json_dict(json_dict) File "/dat01/jttang/wpc/information_extraction/SciREX/SciREX/scirex/data/dataset_readers/scirex_full_reader.py", line 34, in clean_json_dict entities: List[Tuple[int, int, BaseEntityType]] = json_dict["ner"] KeyError: 'ner'

You mentioned new dataset only needs "doc_id","words","sentences","sections" fileds,but the code requires "ner" field. Could you show me some solutions, Thanks.

successar commented 3 years ago

Hi I made a update. Can you see if it still giving you errors ?

muguruzawang commented 3 years ago

Thanks for your update. There's no more problem with a little modest adjustment