I am using the stanza NLP library which uses a decorator to register processors. Stanza has a help page for building your own processors here
They use a class decorator @register_processor("processor_name")
. The code for register_processor
appears pretty simple. It puts the name of the processor in a dict as the key and the class as the value.
It is unclear to me when the decorator, or the function attached to this decorator is called. Is it called just before the class it initialised or at some other point?
I did try Google searching, I found lots on how to use decorators and when function decorators are called but I couldn't find this specific answer on class decorators easily.