Running the ner.correct recipe from command prompt results in exception

I have trained a custom NER Spacy model that I want now to correct/improve using the ner.correct recipe.

I have saved the model using the command nlp.save('D:\DIGITAL_LIBRARY\Brain\Spacy_model')

We can see that the model has been saved in this address in the snapshot below:

According to the documentation the syntax of the ner.correct recipe is the following:

The documentation of this recipe states:

The documentation does not provide an example. I consider logical to assume that I must replace the keyword (argument) spacy_model in the ner.correct recipe with the full name path created when I saved the custom Spacy NER model, i.e. in my case: 'D:\DIGITAL_LIBRARY\Brain\Spacy_model'

Some arguments in the ner.correct recipe are optional and I omit them.

This is my code:

(spcy) C:\prodigy>python -m prodigy ner.correct 'ner_annotations_kak' 'D:\\DIGITAL_LIBRARY\\Brain\\Spacy_model' 'D:\\DIGITAL_LIBRARY\\Brain\\training_data.json'

Let me document this line of code:

python -m : Necessary to run any prodigy command in my system
prodigy ner.correct : I specify the ner recipe to be used
'ner_annotations_kak' : Provide a string that will be used to name the file where the annotations will be saved
'D:\\DIGITAL_LIBRARY\\Brain\\Spacy_model': This is the full path name to my custom trained model
'D:\\DIGITAL_LIBRARY\\Brain\\training_data.json' : This is the full path name to my training data

The command creates an exception and I get back the following error message:

 (spcy) C:\prodigy>python -m prodigy ner.correct 'ner_annotations_kak' 'D:\\DIGITAL_LIBRARY\\Brain\\Spacy_model' 'D:\\DIGITAL_LIBRARY\\Brain\\training_data.json'
Traceback (most recent call last):
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\prodigy\__main__.py", line 60, in <module>
    controller = recipe(*args, use_plac=True)
  File "cython_src\prodigy\core.pyx", line 224, in prodigy.core.recipe.recipe_decorator.recipe_proxy
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\plac_core.py", line 328, in call
    cmd, result = parser.consume(arglist)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\plac_core.py", line 207, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\prodigy\recipes\ner.py", line 194, in make_gold
    nlp = spacy.load(spacy_model)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\spacy\__init__.py", line 30, in load
    return util.load_model(name, **overrides)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\spacy\util.py", line 165, in load_model
    if Path(name).exists():  # path to model data directory
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\pathlib.py", line 1336, in exists
    self.stat()
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\pathlib.py", line 1158, in stat
    return self._accessor.stat(self)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\pathlib.py", line 387, in wrapped
    return strfunc(str(pathobj), *args)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: "'D:\\DIGITAL_LIBRARY\\Brain\\Spacy_model'"

The Windows tell me that the filename is incorrect. I suspect that for some reason, although the documentation informs me that I must pass a string, in this case I should not. So I experiment with this version of the ner.correct recipe and now I get a different error message:

(spcy) C:\prodigy>python -m prodigy ner.correct 'ner_annotations_kak' D:\\DIGITAL_LIBRARY\\Brain\\Spacy_model D:\\DIGITAL_LIBRARY\\Brain\\training_data.json
Traceback (most recent call last):
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\spacy\util.py", line 74, in get_lang_class
    module = importlib.import_module(".lang.%s" % lang, "spacy")
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'spacy.lang.stanza_el'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\prodigy\__main__.py", line 60, in <module>
    controller = recipe(*args, use_plac=True)
  File "cython_src\prodigy\core.pyx", line 224, in prodigy.core.recipe.recipe_decorator.recipe_proxy
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\plac_core.py", line 328, in call
    cmd, result = parser.consume(arglist)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\plac_core.py", line 207, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\prodigy\recipes\ner.py", line 194, in make_gold
    nlp = spacy.load(spacy_model)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\spacy\__init__.py", line 30, in load
    return util.load_model(name, **overrides)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\spacy\util.py", line 166, in load_model
    return load_model_from_path(Path(name), **overrides)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\spacy\util.py", line 196, in load_model_from_path
    cls = get_lang_class(lang)
  File "C:\Users\Alienware\Anaconda3\envs\spcy\lib\site-packages\spacy\util.py", line 76, in get_lang_class
    raise ImportError(Errors.E048.format(lang=lang, err=err))
ImportError: [E048] Can't import language stanza_el from spacy.lang: No module named 'spacy.lang.stanza_el'

Now the error is : ModuleNotFoundError: No module named 'spacy.lang.stanza_el'

This perplexes me. Obviously if the module was not installed I would not have been able to train my custom model which uses exactly this pretrained model.

Here is a snaphshot from my Jupyter Notebook where I compose my code which shows that the model has been downloaded:

In the past you have refused to answer questions labeling them off topic. I would be surprised if you found this question off topic as well. I would be surprised because of the fact the software has been duly paid and you have a reputation to guard.

Hi! I think the problem here was that you quoted the path? Everything you pass in on the command line is a string, and how to specify paths to a file or directory on the CLI depends on the operating system and your shell. (None of this is really related to Prodigy itself btw and Prodigy doesn't do anything differently here from other command line applications.) Btw, you can typically find examples of the documented recipe commands below the table documenting the arguments.

About your other question: Yes, as stated in the spacy-stanza docs, it's currently not expected that you can load a model from just a path – it always requires the library to be present in the environment and the entry points it registers, as well as the loaded data. I actually just answered a question and gave a solution the other day:

This forum is dedicated to questions specifically around Prodigy and I put a lot of effort into answering questions and giving specific tips and advice around NLP and annotation, even on topics that far exceed "how to use Prodigy". We've also written very extensive documentation and produced a variety of tutorials. Sometimes Prodigy questions also touch on spaCy, since we ship with spaCy support and that's fine.

However, we're not able to answer general-purpose usage questions around spaCy or other open-source packages like spacy-stanza on here. Prodigy is provided "as is" for a very fair price – it does not come with a support contract or guaranteed forum responses. If that's what you're looking for, you might cosider hiring a consultant. If you're not happy with this, no problem – just email us and we're happy to issue you a full refund.

I honestly don't think it's fair to complain about the level of help, tips and advice we provide on here for the community, for free, ever day.

1 Like

You have done a great job with Spacy and you continue pushing the envelope. I would propose that you view the questions you receive --like the one I just posted-- as opportunities to add value and not as annoying hassle. My friendly advice would be to enrich your documentation with examples that address questions you are receiving -- to the extend that this is possible. So to be specific, you could create a beginning to end example of how to go about using a stanza-spacy model --once trained-- with prodigy. Mainly self-documented code with some necessary comments to reduce cognitive load. Thank you for your willingness to refund the purchase. I will give it a second try and if I become really desperate I will take advantage of your offer. PS. I understand that you may have different priorities, it is your decision not mine.

Alex, if your overall feeling is that you appreciate the work being put in and that we've been doing a good job, I think you should reconsider how you're coming across here.

The simple and abundantly obvious thing is that we do listen extensively to user feedback and think about what is or isn't difficult. We also do improve our examples. But this doesn't mean that there will always be an example available for every combination of technologies, that does exactly the thing you personally are setting out to do.

I labelled your other questions as off-topic because they related specifically to spaCy rather than Prodigy, and also because you're simply opening too many issues.

It's not fair to our community if we spend hours personally answering a minority of users, while everyone else is waiting patiently for updates. And so there is a limit to how many questions we can answer to a single user, especially questions which are already addressed in the existing documentation and threads.

I am going to unlist the questions you have recently opened. Please stop opening more threads or I will remove your access to this forum. You can choose whether you want to keep using Prodigy or not. I understand if you want a refund, that is no problem.