diff --git a/owlapy/scripts/run.py b/owlapy/scripts/run.py new file mode 100644 index 0000000..ba779f5 --- /dev/null +++ b/owlapy/scripts/run.py @@ -0,0 +1,52 @@ +import argparse +from owlapy.owl_reasoner import SyncReasoner + +inference_types = ["InferredClassAssertionAxiomGenerator", + "InferredSubClassAxiomGenerator", + "InferredDisjointClassesAxiomGenerator", + "InferredEquivalentClassAxiomGenerator", + "InferredEquivalentDataPropertiesAxiomGenerator", + "InferredEquivalentObjectPropertyAxiomGenerator", + "InferredInverseObjectPropertiesAxiomGenerator", + "InferredSubDataPropertyAxiomGenerator", + "InferredSubObjectPropertyAxiomGenerator", + "InferredDataPropertyCharacteristicAxiomGenerator", + "InferredObjectPropertyCharacteristicAxiomGenerator"] + + +def get_default_arguments(description=None): + parser = argparse.ArgumentParser(add_help=False) + parser.add_argument("--path_ontology", type=str, default="KGs/Family/family-benchmark_rich_background.owl", + help="The path of a folder containing the ontology" + ",e.g., KGs/Family/family-benchmark_rich_background.owl.") + parser.add_argument("--inference_types", type=str, default="all", + nargs='+', + choices=inference_types + ["all"], + help="The type of axioms that you want to infer. This argument accepts multiple values." + "You can use 'all' to infer all of them.") + + parser.add_argument("--out_ontology", type=str, default="inferred_axioms_ontology.owl", + help="Path of a file to save the output ontology containing the inferred axioms.") + parser.add_argument("--output_type", type=str, default=None, choices=["ttl", "rdf/xml", "owl/xml"], + help="Filetype of the output ontology.") + + if description is None: + return parser.parse_args() + return parser.parse_args(description) + + +def main(): + + args = get_default_arguments() + sync_reasoner = SyncReasoner(args.path_ontology) + if args.inference_types is "all": + it = inference_types + else: + it = args.inference_types + sync_reasoner.infer_axioms_and_save(output_path=args.out_ontology, output_format=args.output_type, + inference_types=it) + print("Finished inferring axioms \nOutput filename: '{}'".format(args.out_ontology)) + + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index b04bd1b..b24a367 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,7 @@ "License :: OSI Approved :: MIT License", "Topic :: Scientific/Engineering"], python_requires='>=3.10.13', + entry_points={"console_scripts": ["owlapy=owlapy.scripts.run:main"]}, long_description=long_description, long_description_content_type="text/markdown", )