Bug correction into ner.iob-to-gold

Hello guys,
I have the version prodigy version 1.5.
when I did this :

prodigy ner.iob-to-gold input.iob input.json

I’ve got this error :

    Traceback (most recent call last):
      File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
        "__main__", mod_spec)
      File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/usr/local/lib/python3.5/dist-packages/prodigy/__main__.py", line 259, in <module>
        controller = recipe(*args, use_plac=True)
      File "cython_src/prodigy/core.pyx", line 167, in prodigy.core.recipe.recipe_decorator.recipe_proxy
      File "/usr/local/lib/python3.5/dist-packages/plac_core.py", line 328, in call
        cmd, result = parser.consume(arglist)
      File "/usr/local/lib/python3.5/dist-packages/plac_core.py", line 207, in consume
        return cmd, self.func(*(args + varargs + extraopts), **kwargs)
      File "/usr/local/lib/python3.5/dist-packages/prodigy/recipes/ner.py", line 655, in iob_to_gold
        output_file.write(json.dumps(task, sort_keys=True))
    AttributeError: 'PosixPath' object has no attribute 'write'

I took a look into the file /usr/local/lib/python3.5/dist-packages/prodigy/recipes/ner.py and modified “output_file” into “output_loc” in the lines 655,656 and 657

Then it worked perfectly.



Ah, damn, sorry about that! I also just noticed a few other things that were unideal about this recipe, so I fixed those as well. (Just working on the build for v1.5.1 btw.)

Just released v1.5.1, which includes a fix for this! :tada:

In addition to this error, and another one because of a missing import sys, this file also threw me an encoding error, I edited to read the file as utf-8 and it worked.

@Sowmya Ah, damn - already fixed this, thanks! :+1: