Following #141, this PRs add reasoning APIs to OntologyManager, specifically to allow dynamic SWRL rules to be created for instances of an ontology concept class.
Add reason(): reason on ontology concepts and their relations of a specific ontology world. Calling this will generate deducted facts that are updated to contents of property instances.
Basic rules of binary relation (reflexivity, symmetry, transitivity) are introduced. NOTE: These just act as basic examples of rule definitions and more emphasize on the dynamic creation aspect. Same effects could be also achieved but incur creating new property classes, subclassing ReflexiveProperty, SymmetricProperty, TransitiveProperty
Fix a bug causing reasoning to fail, due to missing required specific world as domain of ontology concepts for reasoning.
-> LoadOntology() now by default load from an IRI to the owlready2-provided default_world, which is also by default used for
sync_reasoner_pellet()/sync_reasoner_hermit().
-> Alternatively, create_ontology_world() is added in case of loading ontologies into a custom persistent world & reasoning on it specifically.
test_ontology.py: Add test_reasoning(), also do post-cleaning up of owl/sql, sql-journal files generated during the test.
create_ontology_concept_class()/create_ontology_property_class(): add optional ontology param to allow creating them into a specific ontology namespace, aside from the default main_ontology.
create_ontology_triple_classes():
(1) predicate_name -> predicate_class_name, inverse_predicate_name -> inverse_predicate_class_name for clarity
(2) add predicate_python_attribute_name, inverse_predicate_python_attribute_name, by default taking values from (1) if not explicitly specified, for consistency
Make ontology_object_parent_class type hint as Thing | object to support such an owlready2.FunctionalProperty relation between owlready2.Thing and pure python types
Following #141, this PRs add reasoning APIs to
OntologyManager
, specifically to allow dynamic SWRL rules to be created for instances of an ontology concept class.reason()
: reason on ontology concepts and their relations of a specific ontology world. Calling this will generate deducted facts that are updated to contents of property instances.ReflexiveProperty, SymmetricProperty, TransitiveProperty
LoadOntology()
now by default load from an IRI to the owlready2-provideddefault_world
, which is also by default used forsync_reasoner_pellet()/sync_reasoner_hermit()
. -> Alternatively,create_ontology_world()
is added in case of loading ontologies into a custom persistent world & reasoning on it specifically.test_ontology.py
: Addtest_reasoning()
, also do post-cleaning up ofowl/sql, sql-journal
files generated during the test.create_ontology_concept_class()/create_ontology_property_class()
: add optionalontology
param to allow creating them into a specific ontology namespace, aside from the defaultmain_ontology
.create_ontology_triple_classes()
:predicate_name -> predicate_class_name
,inverse_predicate_name -> inverse_predicate_class_name
for claritypredicate_python_attribute_name, inverse_predicate_python_attribute_name
, by default taking values from (1) if not explicitly specified, for consistencyontology_object_parent_class
type hint asThing | object
to support such anowlready2.FunctionalProperty
relation betweenowlready2.Thing
and pure python types