Have you thought about implementing __contains__ for "man" in model or __getitem__ for model["man"] support? That would be really neat. I tried monkey patching them, but it did not work (not sure why to be honest). The functions could be something like this (I think):
def __getitem__(self, word):
try:
word_idx = self.dictionary[word]
except KeyError:
raise Exception('Word not in dictionary')
return self.word_vectors[word_idx]
def __contains__(self, word):
return word in self.dictionary
I would have done a pull request but I am too uncertain about cython and stuff.
Hey there!
Have you thought about implementing
__contains__
for"man" in model
or__getitem__
formodel["man"]
support? That would be really neat. I tried monkey patching them, but it did not work (not sure why to be honest). The functions could be something like this (I think):I would have done a pull request but I am too uncertain about cython and stuff.