What is the best practice for setting custom extensions and force
#7553
SamEdwardes
started this conversation in
Help: Best practices
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
spaCy has some great documentation on creating custom extensions.
I am confused about how I should use the
force
parameter though in the context of building a custom pipeline component that I plan to turn into a python package.Currently I do set force=True so I avoid the
AttributeError
(from spaCyTextBlob):In reviewing a few other packages I see there are other patterns. What is the "best" pattern? Should I check if the extension is already set? Should I let the error occur? Should I force True?
From negspacy:
From LemmInflect (they handle it in init.py):
From my pending update for spaCyTextBlob that works with spacy 3. In this approach I just check if one of my extensions has been set. If not set then I set them all. The reason being is it seems like a lot of extra lines of code to check each one.
Thank you for your help!
Beta Was this translation helpful? Give feedback.
All reactions