7fa458e2c4c5df5a9d2cc4e66b2472cd9f3377a8,python/baseline/model.py,Tagger,predict_text,#Tagger#Any#,207

Before Change


        if featurizer is None:
            mxlen = kwargs.get("mxlen", self.mxlen if hasattr(self, "mxlen") else len(tokens))
            maxw = kwargs.get("maxw", self.maxw if hasattr(self, "maxw") else max([len(token) for token in tokens]))
            zero_alloc = kwargs.get("zero_alloc", np.zeros)
            featurizer = WordCharLength(self, mxlen, maxw, zero_alloc)

        // This might be inefficient if the label space is large

After Change


        // This might be inefficient if the label space is large

        label_vocab = revlut(self.get_labels())
        batch_dict = dict()
        for k, vectorizer in vectorizers.items():
            value, length = vectorizer.run(tokens, self.embeddings[k].vocab)
            batch_dict[k] = value
            if length is not None:
                batch_dict["{}_lengths".format(k)] = length

        indices = self.predict(batch_dict)[0]
        output = []
        for j in len(tokens):
            output.append((tokens[j], label_vocab[indices[j].item()]))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: dpressel/mead-baseline
Commit Name: 7fa458e2c4c5df5a9d2cc4e66b2472cd9f3377a8
Time: 2018-09-17
Author: dpressel@gmail.com
File Name: python/baseline/model.py
Class Name: Tagger
Method Name: predict_text


Project Name: dpressel/mead-baseline
Commit Name: 2eb4c5f77bd8da9b1e23851b0acb84543e442953
Time: 2018-09-24
Author: dpressel@gmail.com
File Name: python/baseline/pytorch/classify/model.py
Class Name: WordClassifierModelBase
Method Name: make_input


Project Name: dmlc/gluon-nlp
Commit Name: 1e50a6606c5215e0dc28d016bb5f57bd668f47af
Time: 2019-06-06
Author: lausen@amazon.com
File Name: src/gluonnlp/vocab/bert.py
Class Name: BERTVocab
Method Name: from_json