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.