Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ruff, add parameter descriptions #14

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down
114 changes: 113 additions & 1 deletion cmem_plugin_reason/plugin_reason.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down