Skip to content

Commit

Permalink
SyncReasoner optional init using path
Browse files Browse the repository at this point in the history
  • Loading branch information
alkidbaci committed Aug 20, 2024
1 parent 35ecec0 commit 78d9aef
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions owlapy/owl_reasoner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
import operator
from abc import ABCMeta, abstractmethod
from collections import defaultdict
from enum import Enum, auto
from functools import singledispatchmethod, reduce
from itertools import chain, repeat
from types import MappingProxyType, FunctionType
from typing import DefaultDict, Iterable, Dict, Mapping, Set, Type, TypeVar, Optional, FrozenSet, List, cast
from typing import DefaultDict, Iterable, Dict, Mapping, Set, Type, TypeVar, Optional, FrozenSet, List, Union
import logging

import owlready2
Expand All @@ -23,12 +22,11 @@
from owlapy.owl_datatype import OWLDatatype
from owlapy.owl_object import OWLEntity
from owlapy.owl_ontology import OWLOntology, Ontology, _parse_concept_to_owlapy, SyncOntology
from owlapy.owl_ontology_manager import OntologyManager
from owlapy.owl_ontology_manager import SyncOntologyManager
from owlapy.owl_property import OWLObjectPropertyExpression, OWLDataProperty, OWLObjectProperty, OWLObjectInverseOf, \
OWLPropertyExpression, OWLDataPropertyExpression
from owlapy.owl_individual import OWLNamedIndividual
from owlapy.owl_literal import OWLLiteral
from owlapy.owlapi_adaptor import OWLAPIAdaptor
from owlapy.utils import LRUCache

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -1612,7 +1610,7 @@ def _retrieve_triples(self, pe: OWLPropertyExpression) -> Iterable:

class SyncReasoner:

def __init__(self, ontology: SyncOntology, reasoner="HermiT"):
def __init__(self, ontology: Union[SyncOntology, str], reasoner="HermiT"):
"""
OWL reasoner that syncs to other reasoners like HermiT,Pellet,etc.
Expand All @@ -1624,12 +1622,17 @@ def __init__(self, ontology: SyncOntology, reasoner="HermiT"):
assert reasoner in ["HermiT", "Pellet", "JFact", "Openllet"], \
(f"'{reasoner}' is not implemented. Available reasoners: ['HermiT', 'Pellet', 'JFact', 'Openllet']. "
f"This field is case sensitive.")
self.manager = ontology.manager
self.ontology = ontology
if isinstance(ontology, SyncOntology):
self.manager = ontology.manager
self.ontology = ontology
elif isinstance(ontology, str):
self.manager = SyncOntologyManager()
self.ontology = self.manager.load_ontology(IRI.create(ontology))

self._owlapi_manager = self.manager.get_owlapi_manager()
self._owlapi_ontology = self.ontology.get_owlapi_ontology()
# super().__init__(self.ontology)
self.mapper = ontology.mapper
self.mapper = self.ontology.mapper
from org.semanticweb.owlapi.util import (InferredClassAssertionAxiomGenerator, InferredSubClassAxiomGenerator,
InferredEquivalentClassAxiomGenerator,
InferredDisjointClassesAxiomGenerator,
Expand Down

0 comments on commit 78d9aef

Please sign in to comment.