2573c649518391ada6214cfc72d20421dfac4072,src/preprocess.py,,get_embeddings,#Any#Any#Any#,194

Before Change


def get_embeddings(vocab, word2vec, d_word):
    """Get embeddings for the words in vocab"""
    word_v_size = vocab.get_vocab_size("tokens")
    embeddings = np.zeros((word_v_size, d_word))
    for idx in range(word_v_size): // kind of hacky
        word = vocab.get_token_from_index(idx)
        if word == "@@PADDING@@" or word == "@@UNKNOWN@@":
            continue

After Change


def get_embeddings(vocab, vec_file, d_word):
    """Get embeddings for the words in vocab"""
    word_v_size, unk_idx = vocab.get_vocab_size("tokens"), vocab.get_token_index(vocab._oov_token)
    embeddings = np.random.randn(word_v_size, d_word) //np.zeros((word_v_size, d_word))
    with open(vec_file) as vec_fh:
        for line in vec_fh:
            word, vec = line.split(" ", 1)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 4

Instances


Project Name: jsalt18-sentence-repl/jiant
Commit Name: 2573c649518391ada6214cfc72d20421dfac4072
Time: 2018-03-16
Author: wang.alex.c@gmail.com
File Name: src/preprocess.py
Class Name:
Method Name: get_embeddings


Project Name: rtavenar/tslearn
Commit Name: e067d6e72e53409cd58f3aa88312f0cdf0e41133
Time: 2017-06-14
Author: romain.tavenard@univ-rennes2.fr
File Name: tslearn/clustering.py
Class Name: KShape
Method Name: _fit_one_init


Project Name: brightmart/text_classification
Commit Name: 30d1d32c82ec61d78004d2aec4e236804bd61158
Time: 2018-07-18
Author: xuliang@xuliangs-MacBook-Pro.local
File Name: a05_HierarchicalAttentionNetwork/p1_HierarchicalAttention_model_transformer.py
Class Name:
Method Name: test


Project Name: nipy/dipy
Commit Name: 3789de488113316b303be36e2f7d4bb2e405f47f
Time: 2020-10-13
Author: arokem@gmail.com
File Name: dipy/io/tests/test_utils.py
Class Name:
Method Name: test_read_img_arr_or_path