Loading annotations

usage
solved

(Luca) #1

Dear support,
still me :slight_smile:

I’m trying to load annotations and I get an error I cannot understand:

this is an example of annotations:

{'text': '(TMTTF) 2 PF 6', 'label': 'supercon', 'spans': [{'start': 58, 'end': 72, 'label': 'supercon'}], 'meta': {'source': 'Semi-automatic generation'}}
{'text': '(TMTTF) 2 PF 6', 'label': 'supercon', 'spans': [{'start': 1150, 'end': 1164, 'label': 'supercon'}], 'meta': {'source': 'Semi-automatic generation'}}

copied from https://prodi.gy/docs/workflow-first-steps#import-annotations

however I get the following error:

(pyscript) Lucas-MacBook-Pro:prodigy-preprocessing lfoppiano$ prodigy db-in supercon1 output.json.annot-0.jsonl 
Traceback (most recent call last):
  File "cython_src/prodigy/components/loaders.pyx", line 145, in prodigy.components.loaders.JSONL
ValueError: Expected object or value

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/anaconda3/envs/pyscript/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/anaconda3/envs/pyscript/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/anaconda3/envs/pyscript/lib/python3.6/site-packages/prodigy/__main__.py", line 323, in <module>
    plac.call(commands[command], arglist=args, eager=False)
  File "/anaconda3/envs/pyscript/lib/python3.6/site-packages/plac_core.py", line 328, in call
    cmd, result = parser.consume(arglist)
  File "/anaconda3/envs/pyscript/lib/python3.6/site-packages/plac_core.py", line 207, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "/anaconda3/envs/pyscript/lib/python3.6/site-packages/prodigy/__main__.py", line 225, in db_in
    annotations = [set_hashes(eg) for eg in annotations]
  File "/anaconda3/envs/pyscript/lib/python3.6/site-packages/prodigy/__main__.py", line 225, in <listcomp>
    annotations = [set_hashes(eg) for eg in annotations]
  File "cython_src/prodigy/components/loaders.pyx", line 152, in JSONL
ValueError: Failed to load task (invalid JSON).

{'text': '(TMTTF) 2 PF 6', 'label': 'supercon', 's  ...   'meta': {'source': 'Semi-automatic generation'}}

The format looks correct to me: JSONL and the internal structure was copied from your example. Do you have perhaps more extended information about it?

Thank you in advance
Luca


(Ines Montani) #2

The problem here is that JSON expects quotes to be double quotes: ". Your data uses single quotes, which is considered invalid JSON and can’t be loaded.

If you come across JSON errors and you’re not immediately sure what’s wrong, you can also use a JSON validator like this one or install a plugin for your code editor.


(Luca) #3

ouch!

I’m so sorry I overlooked … it was written in big characters in the exception :man_facepalming: