0e52a77af80ef1aefb4958564d67ffbcdd24cc84,torchnlp/encoders/text/spacy_encoder.py,SpacyEncoder,batch_encode,#SpacyEncoder#Any#,79

Before Change


        super().__init__(*args, tokenize=partial(_tokenize, tokenizer=self.spacy), **kwargs)

    def batch_encode(self, sequences):
        return_ = []
        for tokens in self.spacy.pipe(sequences, n_threads=-1):
            text = [token.text for token in tokens]
            vector = [self.stoi.get(token, self.unknown_index) for token in text]
            if self.append_eos:
                vector.append(self.eos_index)
            return_.append(torch.tensor(vector))
        return return_

After Change


        // Batch tokenization is handled by ``self.spacy.pipe``
        original = self.tokenize
        self.tokenize = lambda sequence: [token.text for token in sequence]
        return_ = super().batch_encode(self.spacy.pipe(sequences))
        self.tokenize = original
        return return_
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 6

Instances


Project Name: PetrochukM/PyTorch-NLP
Commit Name: 0e52a77af80ef1aefb4958564d67ffbcdd24cc84
Time: 2019-04-09
Author: petrochukm@gmail.com
File Name: torchnlp/encoders/text/spacy_encoder.py
Class Name: SpacyEncoder
Method Name: batch_encode


Project Name: dnouri/skorch
Commit Name: 892065c8339f9c20d36127645ba3ae169577f47b
Time: 2020-06-27
Author: b.bossan@gmail.com
File Name: skorch/classifier.py
Class Name: NeuralNetClassifier
Method Name: predict


Project Name: Rostlab/nalaf
Commit Name: ebe4256914107273feb1da940fc3e4237731365e
Time: 2016-11-11
Author: i@juanmi.rocks
File Name: nalaf/preprocessing/edges.py
Class Name: SimpleEdgeGenerator
Method Name: generate


Project Name: facebookresearch/pytext
Commit Name: fa0fea934bad76e9906c013e377ce80c77cbd5e4
Time: 2019-01-03
Author: geoffreygoh@fb.com
File Name: pytext/trainers/hogwild_trainer.py
Class Name: HogwildTrainer
Method Name: train