Esempio n. 1
0
    'loves', 'hates', 'likes', 'smells', 'touches', 'pushes', 'moves', 'sees',
    'lifts', 'hits'
]

if __name__ == "__main__":

    np.random.seed(seed=9)
    random.seed(9)

    # Preprocess Corpus
    glove_list, bert_list = RSA.preprocess_data('./head_adj_trans_corpus.txt')
    print("data processed")

    # Generate glove hypothesis models
    embed_dict = RSA.get_glove_embeds(
        glove_list, "../../glove_utils/glove/glove.6B.300d.txt", 300,
        lexical_idxs, verb_list)
    adj1 = np.array(embed_dict[lexical_idxs[0]])
    subj = np.array(embed_dict[lexical_idxs[1]])
    verb = np.array(embed_dict[lexical_idxs[2]])
    adj2 = np.array(embed_dict[lexical_idxs[3]])
    obj = np.array(embed_dict[lexical_idxs[4]])
    rand_verb = np.array(embed_dict[-1])
    print("glove embeds generated")

    # Generate BERT reference model
    bert_embeds = RSA.get_bert_embeds(bert_list, 0)
    print("BERT embeds generated")

    rsa_subj_dist = []
    rsa_obj_dist = []
Esempio n. 2
0
    'tables', 'doors', 'windows', 'planes', 'cars', 'trucks'
]

if __name__ == "__main__":

    np.random.seed(seed=9)
    random.seed(9)

    # Preprocess corpus
    glove_list, bert_list = RSA.preprocess_data('./copula_PP_corpus.txt',
                                                noun_list)
    print("data processed")

    # Get dictionary of Glove embedding hypothesis models
    embed_dict = RSA.get_glove_embeds(
        glove_list, "../../glove_utils/glove/glove.6B.300d.txt", 300,
        noun_idxs, noun_list, verb_idx)
    glove_subj = np.array(embed_dict[noun_idxs[0]])
    glove_nonarg = np.array(embed_dict[noun_idxs[1]])
    glove_rand = np.array(embed_dict[-1])
    print("glove embeds generated")

    # Get BERT embedding reference models
    bert_embeds = RSA.get_bert_embeds(bert_list, verb_idx + 1)
    print("BERT embeds generated")

    rsa_subj_dist = []
    rsa_nonarg_dist = []
    rsa_rand_dist = []

    samples = []