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:]] # Get prediction values for each feature using weight matrix and bias terms values = ex.predict_feats(W, b_arr, vect) # Part 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:]] # Get prediction values for each feature using weight matrix and bias terms values = ex.predict_feats(W, b_arr, vect) # create dict to hold expanded features
if __name__ == "__main__": # Get feature vectors print "generating feature vectors..." features_index = u.read_features_file("output-700/feat-space.txt") feature_size = len(features_index) target_words = u.get_target_words() # Now let's do SCL print "getting targets..." targets = u.get_target_words() # Load target word weight vectors as rows into matrix W print "creating W..." W, _ = u.get_weight_matrix(targets) # Perform SVD on W print "performing SVD(W)..." WT = W.T # SVD returns U, S, V.T U, S, VT = numpy.linalg.svd(WT, full_matrices=False) #print "W" #print W.shape #print "WT" #print WT.shape #print "" #print U #print "U"