required=True, help="number of action predicates in each rule") cl_args = parser.parse_args() background_fname_train = cl_args.background_train facts_fname_train = cl_args.facts_train pos_fname_train = cl_args.pos_train neg_fname_train = cl_args.neg_train background_fname_test = cl_args.background_test facts_fname_test = cl_args.facts_test pos_fname_test = cl_args.pos_test neg_fname_test = cl_args.neg_test rulelen = int(cl_args.rule_length) numrules = int(cl_args.num_rules) dfs_train = load_metadata(background_fname_train) load_data(facts_fname_train, dfs_train) load_labels(pos_fname_train, dfs_train, 1.0) load_labels(neg_fname_train, dfs_train, 0.0) tails_relation_train = None labels_df_train = None action_attr = None sentence_attr = None action_relations_train = [] action_rel_names_train = [] for name, df in dfs_train.items(): colnames = df.columns.values.tolist() if "Label" in colnames: labels_df_train = df sentence_attr = colnames[0]
help="the target predicate") parser.add_argument("-m", "--model", required=True, help="file to read the model from") cl_args = parser.parse_args() background_fname = cl_args.background facts_fname_test = cl_args.facts_test target = cl_args.target fin = cl_args.model (attr_name, labels_df_train, disj, rel_names_train) = dill.load(open(fin, 'rb')) dfs_test = load_metadata(background_fname) load_data(facts_fname_test, dfs_test) labels_df_test = dfs_test[target] labels_df_test.columns = [attr_name + "0", attr_name + "3"] true_links = pd.concat([labels_df_train, labels_df_test]) true_links = true_links.loc[true_links['Relation'] == target] true_links.drop(['Relation'], axis=1, inplace=True) cols = true_links.columns.tolist() inv_true_links = true_links[[cols[1], cols[0]]].copy() inv_true_links.columns = [cols[0], cols[1]] mask = [1] * len(rel_names_train) pos = rel_names_train.index(target)
help="file containing schema information") parser.add_argument("-ftr", "--facts_train", required=True, help="file containing facts for training") parser.add_argument("-m", "--model", required=True, help="file to write the model in") cl_args = parser.parse_args() background_fname = cl_args.background facts_fname_train = cl_args.facts_train fout = cl_args.model dfs_train = load_metadata(background_fname) load_data(facts_fname_train, dfs_train) attr_name = None relations_train = [] rel_names_train = [] choices = [] for name, df in dfs_train.items(): colnames = df.columns.values.tolist() attr_name = colnames[0] df.columns = [attr_name + "0", attr_name + "1"] choices.append(name) rel_names_train.append(name) relations_train.append(df)