Skip to content

owlapi_interface

Python interface to the FaCT++ Reasoner.

This module is copied from the SimPhoNy project.

Original author: Matthias Urban

OwlApiInterface

Interface to the FaCT++ reasoner via OWLAPI.

__init__(self) special

Initialize the interface.

Source code in ontopy/factpluspluswrapper/owlapi_interface.py
def __init__(self):
    """Initialize the interface."""
    pass

merge_files(self, *owl_files)

Merge the given owl files and its import closure.

Parameters:

Name Type Description Default
owl_files os.path

The owl files two merge

()
Source code in ontopy/factpluspluswrapper/owlapi_interface.py
def merge_files(self, *owl_files):
    """Merge the given owl files and its import closure.

    Args:
        owl_files (os.path): The owl files two merge
    """
    return self._run(*owl_files, command="--merge-only")

reason(self, graph)

Generate the inferred axioms for a given Graph.

Parameters:

Name Type Description Default
graph Graph

An rdflib graph to execute the reasoner on.

required
Source code in ontopy/factpluspluswrapper/owlapi_interface.py
def reason(self, graph):
    """Generate the inferred axioms for a given Graph.

    Args:
        graph (Graph): An rdflib graph to execute the reasoner on.
    """
    with tempfile.NamedTemporaryFile("wt") as f:
        graph.serialize(f.name, format="xml")
        return self._run(f.name, command="--run-reasoner")

reason_files(self, *owl_files)

Merge the given owl and generate the inferred axioms.

Parameters:

Name Type Description Default
owl_files os.path

The owl files two merge

()
Source code in ontopy/factpluspluswrapper/owlapi_interface.py
def reason_files(self, *owl_files):
    """Merge the given owl and generate the inferred axioms.

    Args:
        owl_files (os.path): The owl files two merge
    """
    return self._run(*owl_files, command="--run-reasoner")

reason_from_terminal()

Run the reasoner from terminal.

Source code in ontopy/factpluspluswrapper/owlapi_interface.py
def reason_from_terminal():
    """Run the reasoner from terminal."""
    parser = argparse.ArgumentParser(
        description="Run the FaCT++ reasoner on the given OWL file. "
        "Catalog files are used to load the import closure. "
        "Then the reasoner is executed and the inferred triples are merged "
        "with the asserted ones. If multiple OWL files are given, they are "
        "merged beforehand"
    )
    parser.add_argument("owl_file", nargs="+",
                        help="OWL file(s) to run the reasoner on.")
    parser.add_argument("output_file",
                        help="Path to store inferred axioms to.")

    args = parser.parse_args()
    OwlApiInterface()._run(*args.owl_file, command="--run-reasoner",
                           return_graph=False, output_file=args.output_file)
Back to top