-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Fix save/load_word2vec_format
methods for FastText
model. Fix #1743
#1755
Conversation
save/load_word2vec_format
for FastText
modelssave/load_word2vec_format
for FastText
models
gensim/models/fasttext.py
Outdated
@@ -243,6 +243,14 @@ def word_vec(self, word, use_norm=False): | |||
def load_fasttext_format(cls, *args, **kwargs): | |||
return Ft_Wrapper.load_fasttext_format(*args, **kwargs) | |||
|
|||
@classmethod | |||
def load_word2vec_format(cls, fname, fvocab=None, binary=False, encoding='utf8', unicode_errors='strict', |
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.
Necessary? Personally, I would leave this out. I don't see any problem with getting a "deprecation error" instead of "not implemented error". Plus, it's weird to call a method that you know will fail. This is likely to cause more confusion than good. @menshikh-iv, what do you think?
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.
Makes sense. Removing this function from here.
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.
@janpom agree with you
@manneshiva please resolve merge conflict |
gensim/models/wrappers/fasttext.py
Outdated
@@ -137,6 +137,12 @@ def __contains__(self, word): | |||
char_ngrams = compute_ngrams(word, self.min_n, self.max_n) | |||
return any(ng in self.ngrams for ng in char_ngrams) | |||
|
|||
@classmethod | |||
def load_word2vec_format(cls, fname, fvocab=None, binary=False, encoding='utf8', unicode_errors='strict', |
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.
One tiny change I might suggest here would be to use *args and **kwargs instead. I like following this practice in situations where the subclass doesn't make use of the function params itself. It is useful because if any params in the parent class change in the future, the subclass function signature doesn't have to be modified.
save/load_word2vec_format
for FastText
modelssave/load_word2vec_format
methods for FastText
model. Fix #1743
This PR addresses #1743 by disabling
load_word2vec_format
call forFastText
models.