olaf.pipeline.pipeline_component.axiom_extraction package¶
Submodules¶
olaf.pipeline.pipeline_component.axiom_extraction.llm_based_axiom_extraction module¶
- class olaf.pipeline.pipeline_component.axiom_extraction.llm_based_axiom_extraction.LLMBasedOWLAxiomExtraction(prompt_template: Callable[[str], List[Dict[str, str]]] | None = None, llm_generator: LLMGenerator | None = None, namespace: str | None = None)[source]¶
Bases:
PipelineComponent
LLM based OWL axiom extraction.
Attributes¶
- prompt_template: Callable[[str], List[Dict[str, str]]]
Prompt template used to give instructions and context to the LLM.
- llm_generator: LLMGenerator
The LLM model used to generate axioms.
- namespace: str
The name space used for axiom generation, by default “http://www.ms2.org/o/example#”.
- check_resources() None [source]¶
Method to check that the component has access to all its required resources.
- get_performance_report() Dict[str, Any] [source]¶
A getter for the pipeline component performance report. If the component has been optimised, it only returns the best performance. Otherwise, it returns the results obtained with the set parameters.
Returns¶
- Dict[str, Any]
The pipeline component performance report.
olaf.pipeline.pipeline_component.axiom_extraction.owl_axiom_extraction module¶
- class olaf.pipeline.pipeline_component.axiom_extraction.owl_axiom_extraction.OWLAxiomExtraction(owl_axiom_generators: Set[Callable[[KnowledgeRepresentation, URIRef], Graph]], base_uri: str | URIRef | None = None, reasoner: str | None = 'ELK')[source]¶
Bases:
PipelineComponent
The OWL axiom extraction component inductively construct OWL axioms from the knowledge representation based on some OWL ontology modeling patterns.
The component generates the OWL ontology based on the provided patterns, test its semantic consistence with an OWL reasoner and remove axioms until the ontology is consistent.
This component requires the environment variables: - “JAVA_EXE” - “ROBOT_JAR”
Attributes¶
- owl_axiom_generatorsSet[Callable[[KnowledgeRepresentation, URIRef], Graph]]
The function to generate the OWL axioms.
- base_uriUnion[str, URIRef], optional
The base URI to use when creating the concepts and relations URIs, by default “http://www.ms2.org/o/example#”.
- reasonerstr, optional
The reasoner to use, by default “ELK”. Reasoning is performed using the ROBOT CLI: <https://robot.obolibrary.org/reason>. Hence, possible values are: “hermit”, “jfact”, “whelk”, “emr”, “structural”
- java_exe: str
Environment variable path to the Java executable.
- robot_jar: str
Environment variable path to the ROBOT CLI .jar file.
- graph_to_test_temp_file: PathLike
Temporary file path to store intermediate RDF graphs for consistency check.
- tested_graph_temp_file: PathLike
Temporary file path for the inferred triples.
- _pattern_nb_classes: str
Regex pattern to match the number of unsatisfiable classes in the ROBOT CLI error message.
- _pattern_unsatisfiable_classes: str
Regex pattern to match the unsatisfiable classes URIs in the ROBOT CLI error message.
- individuals_axiom_generators: Set[Set[Callable[[KnowledgeRepresentation, URIRef], Graph]]]
A set of the possible OWL axiom generators creating OWL named individuals.
- build_full_graph(kr: KnowledgeRepresentation) Graph [source]¶
Build the complete RDF graph based on the provided OWL axiom generators.
Parameters¶
- krKnowledgeRepresentation
The knowledge representation to use when build the graph.
Returns¶
- Graph
The constructed RDF graph.
- build_graph_without_owl_instances(kr: KnowledgeRepresentation) Graph [source]¶
Build the RDF graph based on the provided OWL axiom generators omitting the ones creating OWL named instances.
Parameters¶
- krKnowledgeRepresentation
_description_
Returns¶
- Graph
_description_
- check_resources() None [source]¶
Method to check that the component has access to all its required resources.
The OWL axiom extraction component requires the environment variables: - “JAVA_EXE” - “ROBOT_JAR”
- get_performance_report() Dict[str, Any] [source]¶
- A getter for the pipeline component performance report.
If the component has been optimised, it only returns the best performance. Otherwise, it returns the results obtained with the set parameters.
Returns¶
- Dict[str, Any]
The pipeline component performance report.