820ad912dda0b5cbe49c53762374deb6bedd1299,tools/embeddings_to_torch.py,,get_vocabs,#Any#,13

Before Change


    fields = torch.load(dict_path)

    if old_style_vocab(fields):
        enc_vocab = next((v for n, v in fields if n == "src"), None)
        dec_vocab = next((v for n, v in fields if n == "tgt"), None)
    else:
        enc_vocab = fields["src"][0][1].vocab
        dec_vocab = fields["tgt"][0][1].vocab

After Change


def get_vocabs(dict_path):
    fields = torch.load(dict_path)

    vocs = []
    for side in ["src", "tgt"]:
        if _old_style_vocab(fields):
            vocab = next((v for n, v in fields if n == side), None)
        else:
            try:
                vocab = fields[side][0][1].base_field.vocab
            except AttributeError:
                vocab = fields[side][0][1].vocab
        vocs.append(vocab)
    enc_vocab, dec_vocab = vocs

    logger.info("From: %s" % dict_path)
    logger.info("\t* source vocab: %d words" % len(enc_vocab))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 9

Instances


Project Name: OpenNMT/OpenNMT-py
Commit Name: 820ad912dda0b5cbe49c53762374deb6bedd1299
Time: 2019-02-01
Author: dylan.flaute@gmail.com
File Name: tools/embeddings_to_torch.py
Class Name:
Method Name: get_vocabs


Project Name: OpenNMT/OpenNMT-py
Commit Name: 68fbfd1876c367323acf830736bae1af499cc0fe
Time: 2018-03-07
Author: dengyuntian@gmail.com
File Name: onmt/io/TextDataset.py
Class Name: TextDataset
Method Name: __init__


Project Name: keras-team/keras
Commit Name: 555ca942df407b8c1bf1d48383c60fa1bf09cc1d
Time: 2019-08-28
Author: francois.chollet@gmail.com
File Name: keras/engine/network.py
Class Name: Network
Method Name: losses


Project Name: keras-team/keras
Commit Name: bf464d7ed9283988fea1f548a11a0171fd2ff364
Time: 2021-01-06
Author: gardener@tensorflow.org
File Name: keras/utils/version_utils.py
Class Name:
Method Name: swap_class