-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Standardize spacy #347
base: main
Are you sure you want to change the base?
Standardize spacy #347
Conversation
…o standardize_spacy
@@ -13,15 +13,39 @@ | |||
glove = None | |||
|
|||
|
|||
def initialize_models(): | |||
def initialize_models(model: str = "spacy", lang: str = "en"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are making it generic, it would be great if we can create an enum for all heavy models which we want to load.
Because in future it may increase.
Something like:
LoadOnceModel.SPACY,
LoadOnceModel.GLOVE
spacy_nlp = spacy.load("fr_core_news_sm") | ||
elif model == "glove": | ||
# load glove | ||
glove = vocab.GloVe(name="6B", dim="100") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have an 'else' block also where we can throw an exception with an unsupported message. (if it doesn't match any model name)
# load glove | ||
glove = vocab.GloVe(name = "6B", dim = "100") | ||
if model == "spacy": | ||
if lang == "en": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cosmetic Change (line 36-45): Better to create a map of 'lang' vs 'spacy model name' which will eliminate multiple lines of code.
spacy_nlp = spacy.load("en_core_web_sm") | ||
elif lang == "es": | ||
spacy_nlp = spacy.load("es_core_news_sm") | ||
elif lang == "zh": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it more informative, can we add a log message of whatever model we are loading as there are multiple models?
Something like:
"Loading zh_core_web_sm model of spacy......."
Sure @aadesh11. Will address the comments. This PR might take a while to complete :) |
@AbinayaM02 should we close this PR? |
Hi @kaustubhdhole: I wanted to standardize the loading of all spacy models in a single place. Not finding time to finish it. Let it be on draft and I'll try to close it once the first release is done (hopefully soon)! :) |
Fixes #339.