Invalid JSON on line 1 in the patterns file

I've created the patterns file using:

python -m prodigy terms.to-patterns relatives_terms --label RELATIVES --spacy-model blank:en > ./relatives_patterns.jsonl

If I start with manual NER annotation by

python -m prodigy ner.manual relatives_data blank:en ./relatives_sample.jsonl --label RELATIVES --patterns ./relatives_patterns.jsonl

I'll get an error:

ValueError: Invalid JSON on line 1: {"label":"RELATIVES","pattern":[{"lower":"aunt"}]}

Hi! That's strange, the example JSON looks fine and under the hood, terns.to-patterns just calls json.dumps. How does the whole JSONL file look? Any weird line endings or something like that?

Hi, Ines! I had the encoding issue. The terms.to-patterns created the file not encoded in "UTF-8" (аlthough python -c 'import sys; print(sys.getdefaultencoding()) returns utf-8 ). I had changed the encoding by Notepad++ then I got "Invalid JSON" error. Now I'm doing it in another way and it works for me.
Thanks!

1 Like