6a5916968838686e332fb68a10cb30222843fbd9,torchnlp/word_to_vector/pretrained_word_vectors.py,_PretrainedWordVectors,__getitem__,#_PretrainedWordVectors#Any#,77

Before Change


        return token in self.stoi

    def __getitem__(self, token):
        if token in self.stoi:
            return self.vectors[self.stoi[token]]
        else:
            return self.unk_init(torch.Tensor(self.dim))

    def __len__(self):
        return len(self.vectors)

    def __str__(self):

After Change


        if isinstance(tokens, list) or isinstance(tokens, tuple):
            vector_list = [self._get_token(token) for token in tokens]
            return torch.stack(vector_list)
        elif isinstance(tokens, str):
            token = tokens
            return self._get_token(token)
        else:
            raise TypeError(""__getitem__" method can only be used with types"
                            ""str", "list", or "tuple" as parameter")
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: PetrochukM/PyTorch-NLP
Commit Name: 6a5916968838686e332fb68a10cb30222843fbd9
Time: 2018-04-26
Author: florian.joh.schaefer@gmail.com
File Name: torchnlp/word_to_vector/pretrained_word_vectors.py
Class Name: _PretrainedWordVectors
Method Name: __getitem__


Project Name: open-mmlab/mmdetection
Commit Name: dd2907ed70a9f29ecbe2fba75de735e96daae3a2
Time: 2018-11-26
Author: chenkaidev@gmail.com
File Name: mmdet/ops/nms/nms_wrapper.py
Class Name:
Method Name: nms


Project Name: geomstats/geomstats
Commit Name: a2e39e8a3c0586ce0c1cca407d1738565a75e705
Time: 2020-01-16
Author: ninamio78@gmail.com
File Name: geomstats/backend/pytorch_random.py
Class Name:
Method Name: choice