Пример #1
0
    # Method variables
    # n (path length) should be either 1 or 2
    # note: tried 3, but didn't give good results, so now code is limited to 1 or 2
    n = 1
    input_file = "test-full-new.txt"
    output_file = "test-local-path-1.txt"

    # Generate graph from edges file
    G = ex.read_graph(c.output_dir + "edges-directed-6.txt")

    # Get feature space and target words
    features_index = u.read_features_file(c.output_dir + "feat-space.txt")
    target_words = u.get_target_words()

    # Get sentences/vectors of data to expand
    sentences, data = ex.get_expansion_data(input_file, features_index)

    # Get matrix of weight vectors
    print "generating weight matrix..."
    W, b_arr = u.get_weight_matrix(target_words)

    # Iterate over instances and expand them
    print "expanding feature vectors..."
    i = 0
    for vect in data:
        #if i == 3:
        #    break

        # Store array of current feats
        feats = [f.split(":")[0] for f in sentences[i][1:]]
if __name__ == "__main__":
    # Method variables
    #predict_threshold = 0.9 # prediction threshold
    
    input_file = "test-full.txt"
    output_file = "test-expanded-all-neighb.txt"
    
    # Generate graph from edges file
    G = ex.read_graph(c.output_dir + "edges-directed-6.txt")
    
    # Get feature space and target words
    features_index = u.read_features_file(c.output_dir + "feat-space.txt")
    target_words = u.get_target_words()
    
    # Get sentences/vectors of data to expand
    sentences, data = ex.get_expansion_data(input_file, features_index)
    
    # Get matrix of weight vectors
    print "generating weight matrix..."
    W, b_arr = u.get_weight_matrix(target_words)
    
    
    print "expanding feature vectors..."
    i = 0
    for vect in data:
        #if i == 5:
        #    break
        
        # Store array of current feats
        feats = [f.split(":")[0] for f in sentences[i][1:]]