From 693f676141896745a011a2c2b1101757c9918274 Mon Sep 17 00:00:00 2001 From: muddymudskipper Date: Thu, 29 Aug 2024 08:33:57 +0100 Subject: [PATCH] fix ruff, add parameter descriptions --- CHANGELOG.md | 6 +- cmem_plugin_reason/plugin_reason.py | 114 +++++++++++++++++++++++++++- tests/test_validate.py | 2 +- 3 files changed, 119 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d423986..17b1c9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [unreleased] +### Added + +- axiom generator description in UI + ### Changed - output graph label derived from input graph @@ -23,7 +27,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Changed - Validate: the entity output includes the reasoner option on path "reason" - - Detailed axiom generator documentation + - detailed axiom generator documentation - The axiom generator ObjectPropertyCharacteristic does not yield results. Currently, this axiom generator and its (working) counterpart DataPropertyCharacteristic are removed from the Reason plugin. diff --git a/cmem_plugin_reason/plugin_reason.py b/cmem_plugin_reason/plugin_reason.py index 2ecbc2f..1ca8192 100644 --- a/cmem_plugin_reason/plugin_reason.py +++ b/cmem_plugin_reason/plugin_reason.py @@ -36,7 +36,105 @@ validate_profiles, ) -REASONER_PARAMETER.description += " Select axiom generators below [Click (?) for documentation]." +SUBCLASS_DESC = """The reasoner will infer assertions about the hierarchy of classes, i.e. +`SubClassOf:` statements.\n +If there are classes `Person`, `Student` and `Professor`, such that `Person DisjointUnionOf: +Student, Professor` holds, the reasoner will infer `Student SubClassOf: Person`. +""" + +EQUIVALENCE_DESC = """The reasoner will infer assertions about the equivalence of classes, i.e. +`EquivalentTo:` statements.\n +If there are classes `Person`, `Student` and `Professor`, such that `Person DisjointUnionOf: +Student, Professor` holds, the reasoner will infer `Person EquivalentTo: Student and Professor`. +""" + +DISJOINT_DESC = """The reasoner will infer assertions about the disjointness of classes, i.e. +`DisjointClasses:` statements.\n +If there are classes `Person`, `Student` and `Professor`, such that `Person DisjointUnionOf: +Student, Professor` holds, the reasoner will infer `DisjointClasses: Student, Professor`. +""" + +# DATA_PROP_CHAR_DESC = """The reasoner will infer characteristics of data properties, i.e. +# `Characteristics:` statements. For data properties, this only pertains to functionality.\n +# If there are data properties `identifier` and `enrollmentNumber`, such that `enrollmentNumber +# SubPropertyOf: identifier` and `identifier Characteristics: Functional` holds, the reasoner will +# infer `enrollmentNumber Characteristics: Functional`. +# """ + +DATA_PROP_EQUIV_DESC = """The reasoner will infer axioms about the equivalence of data properties, + i.e. `EquivalentProperties` statements.\n +If there are data properties `identifier` and `enrollmentNumber`, such that `enrollmentNumber +SubPropertyOf: identifier` and `identifier SubPropertyOf: enrollmentNumber` holds, the reasoner +will infer `Student EquivalentProperties: identifier, enrollmentNumber`. +""" + +DATA_PROP_SUB_DESC = """The reasoner will infer axioms about the hierarchy of data properties, +i.e. `SubPropertyOf:` statements.\n +If there are data properties `identifier`, `studentIdentifier` and `enrollmentNumber`, such that +`studentIdentifier SubPropertyOf: identifier` and `enrollmentNumber SubPropertyOf: +studentIdentifier` holds, the reasoner will infer `enrollmentNumber SubPropertyOf: identifier`. +""" + +CLASS_ASSERT_DESC = """The reasoner will infer assertions about the classes of individuals, i.e. +`Types:` statements.\n +Assume, there are classes `Person`, `Student` and `University` as well as the property +`enrolledIn`, such that `Student EquivalentTo: Person and enrolledIn some University` holds. For +the individual `John` with the assertions `John Types: Person; Facts: enrolledIn +LeipzigUniversity`, the reasoner will infer `John Types: Student`. +""" + +PROPERTY_ASSERT_DESC = """The reasoner will infer assertions about the properties of individuals, +i.e. `Facts:` statements.\n +Assume, there are properties `enrolledIn` and `offers`, such that `enrolled SubPropertyChain: +enrolledIn o inverse (offers)` holds. For the individuals `John`and `LeipzigUniversity` with the +assertions `John Facts: enrolledIn KnowledgeRepresentation` and `LeipzigUniversity Facts: offers +KnowledgeRepresentation`, the reasoner will infer `John Facts: enrolledIn LeipzigUniversity`. +""" + +# OBJECT_PROP_CHAR_DESC = """The reasoner will infer characteristics of object properties, i.e. +# `Characteristics:` statements.\n +# If there are object properties `enrolledIn` and `studentOf`, such that `enrolledIn +# SubPropertyOf: studentOf` and `enrolledIn Characteristics: Functional` holds, the reasoner will +# infer `studentOf Characteristics: Functional`. **Note: this inference does neither work in JFact +# nor in HermiT!** +# """ + +OBJECT_PROP_EQUIV_DESC = """The reasoner will infer assertions about the equivalence of object +properties, i.e. `EquivalentTo:` statements.\n +If there are object properties `hasAlternativeLecture` and `hasSameTopicAs`, such that +`hasAlternativeLecture Characteristics: Symmetric` and `hasSameTopicAs InverseOf: +hasAlternativeLecture` holds, the reasoner will infer `EquivalentProperties: +hasAlternativeLecture, hasSameTopicAs`. +""" + +OBJECT_PROP_SUB_DESC = """The reasoner will infer axioms about the inclusion of object properties, +i.e. `SubPropertyOf:` statements.\n +If there are object properties `enrolledIn`, `studentOf` and `hasStudent`, such that `enrolledIn +SubPropertyOf: studentOf` and `enrolledIn InverseOf: hasStudent` holds, the reasoner will infer +`hasStudent SubPropertyOf: inverse (studentOf)`. +""" + +OBJECT_PROP_INV_DESC = """The reasoner will infer axioms about the inversion about object +properties, i.e. `InverseOf:` statements.\n +If there is a object property `hasAlternativeLecture`, such that `hasAlternativeLecture +Characteristics: Symmetric` holds, the reasoner will infer `hasAlternativeLecture InverseOf: +hasAlternativeLecture`. +""" + +OBJECT_PROP_RANGE_DESC = """The reasoner will infer axioms about the ranges of object properties, +i.e. `Range:` statements.\n +If there are classes `Student` and `Lecture` as wells as object properties `hasStudent` and +`enrolledIn`, such that `hasStudent Range: Student and enrolledIn some Lecture` holds, the +reasoner will infer `hasStudent Range: Student`. +""" + +OBJECT_PROP_DOMAIN_DESC = """The reasoner will infer axioms about the domains of object +properties, i.e. `Domain:` statements.\n +If there are classes `Person`, `Student` and `Professor` as wells as the object property +`hasRoleIn`, such that `Professor SubClassOf: Person`, `Student SubClassOf: Person` and +`hasRoleIn Domain: Professor or Student` holds, the reasoner will infer `hasRoleIn Domain: +Person`. +""" @Plugin( @@ -75,84 +173,98 @@ param_type=BoolParameterType(), name="sub_class", label="Class inclusion (rdfs:subClassOf)", + description=SUBCLASS_DESC, default_value=False, ), PluginParameter( param_type=BoolParameterType(), name="equivalent_class", label="Class equivalence (owl:equivalentClass)", + description=EQUIVALENCE_DESC, default_value=False, ), PluginParameter( param_type=BoolParameterType(), name="disjoint_classes", label="Class disjointness (owl:disjointWith)", + description=DISJOINT_DESC, default_value=False, ), # PluginParameter( # param_type=BoolParameterType(), # name="data_property_characteristic", # label="Data property characteristics (Axiomatic triples)", + # description=DATA_PROP_CHAR_DESC, # default_value=False, # ), PluginParameter( param_type=BoolParameterType(), name="equivalent_data_properties", label="Data property equivalence (owl:equivalentProperty)", + description=DATA_PROP_EQUIV_DESC, default_value=False, ), PluginParameter( param_type=BoolParameterType(), name="sub_data_property", label="Data property inclusion (rdfs:subPropertyOf)", + description=DATA_PROP_SUB_DESC, default_value=False, ), PluginParameter( param_type=BoolParameterType(), name="class_assertion", label="Individual class assertions (rdf:type)", + description=CLASS_ASSERT_DESC, default_value=True, ), PluginParameter( param_type=BoolParameterType(), name="property_assertion", label="Individual property assertions", + description=PROPERTY_ASSERT_DESC, default_value=True, ), PluginParameter( param_type=BoolParameterType(), name="equivalent_object_property", label="Object property equivalence (owl:equivalentProperty)", + description=OBJECT_PROP_EQUIV_DESC, default_value=False, ), PluginParameter( param_type=BoolParameterType(), name="inverse_object_properties", label="Object property inversion (owl:inverseOf)", + description=OBJECT_PROP_INV_DESC, default_value=False, ), # PluginParameter( # param_type=BoolParameterType(), # name="object_property_characteristic", # label="Object property characteristic (Axiomatic triples)", + # description=OBJECT_PROP_CHAR_DESC, # default_value=False, # ), PluginParameter( param_type=BoolParameterType(), name="sub_object_property", label="Object property inclusion (rdfs:subPropertyOf)", + description=OBJECT_PROP_SUB_DESC, default_value=False, ), PluginParameter( param_type=BoolParameterType(), name="object_property_range", label="Object property ranges (rdfs:range)", + description=OBJECT_PROP_RANGE_DESC, default_value=False, ), PluginParameter( param_type=BoolParameterType(), name="object_property_domain", label="Object property domains (rdfs:domain)", + description=OBJECT_PROP_DOMAIN_DESC, default_value=False, ), PluginParameter( diff --git a/tests/test_validate.py b/tests/test_validate.py index 47fb9fd..092275a 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -35,7 +35,7 @@ def get_value_dict(entities: Entities) -> dict: return value_dict -@pytest.fixture() +@pytest.fixture def _setup(request: pytest.FixtureRequest) -> None: """Set up Validate test""" with suppress(Exception):