def prepare_double_relation_classifier_dataset(self, file_path=None): if file_path is None: ds = LC_Qaud() else: ds = LC_Qaud(self.filepath) ds.load() ds.parse() X = [] y = [] for qapair in ds.qapairs: X.append(qapair.question.text) relation_uris = [u for u in qapair.sparql.uris if u.is_ontology() or u.is_type()] if len(relation_uris) != len(set(relation_uris)): y.append(1) else: y.append(0) return X, y
def prepare_question_classifier_dataset(self, file_path=None): if file_path is None: ds = LC_Qaud() else: ds = LC_Qaud(file_path) ds.load() ds.parse() X = [] y = [] for qapair in ds.qapairs: X.append(qapair.question.text) if "COUNT(" in qapair.sparql.raw_query: y.append(2) elif "ASK WHERE" in qapair.sparql.raw_query: y.append(1) else: y.append(0) return X, y
if __name__ == "__main__": parser = argparse.ArgumentParser( description='Analyse the output of query generator') parser.add_argument("--file", help="file name to load the results", default="tmp", dest="file_name") parser.add_argument("--filter", help="file name to filter the results", default="-", dest="filter_name") args = parser.parse_args() ds_1 = load_ds(args.file_name) id_to_include = [] if args.filter_name != "-": ds = LC_Qaud(args.filter_name) ds.load() ds.parse() for item in ds.qapairs: id_to_include.append(item.id) print default(ds_1, id_to_include) # ds_1 = load_ds("wq_14") # print default(ds_1) # bar_chart_per_feature(ds_1)