Exemplo n.º 1
0
def load_train_data():
    kg_embedding_model = triple2vec(20, "../Model/kg_embedding_model/dbpedia_model/e_tr/")
    label2id = load_label2id()

    train_triples = []
    train_labels = []
    for label, content in [line.strip().split('<#>') for line in codecs.open(hp.train_path, 'r', 'utf-8').readlines() if line]:
        train_triples.append(content.strip())
        train_labels.append(label2id[label])

    trans_X, kg_embd_X, Y, Sources, Targets = create_data(train_triples, train_labels, kg_embedding_model)
    return trans_X, kg_embd_X, Y
Exemplo n.º 2
0
def load_test_data():
    kg_embedding_model = triple2vec(20, hp.kg_embd_model_dir)
    label2id = load_label2id()

    train_triples = []
    train_labels = []
    for label, content in [line.strip().split('<#>') for line in codecs.open(hp.test_path, 'r', 'utf-8').readlines() if
                           line]:
        train_triples.append(content.strip())
        train_labels.append(label2id[label])

    # print('len', len(train_sentences), len(train_targets))
    X, Y, Sources, Targets = create_data(train_triples, train_labels, kg_embedding_model)
    return X, Y