Skip to content

Commit

Permalink
Implementing __contains__ for Vectors class (#2144)
Browse files Browse the repository at this point in the history
  • Loading branch information
saeeddhqan authored Apr 6, 2023
1 parent fdc4858 commit f3c34f9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions torchtext/vocab/vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def __getitem__(self, token):
else:
return self.unk_init(torch.Tensor(self.dim))

def __contains__(self, token):
return token in self.stoi

def cache(self, name, cache, url=None, max_vectors=None):
import ssl

Expand Down

0 comments on commit f3c34f9

Please sign in to comment.