From a0f3a3c04ed00fc4a5eedb009ad16af7f4470bfe Mon Sep 17 00:00:00 2001 From: Michael Hanke Date: Tue, 26 Mar 2024 10:19:17 +0100 Subject: [PATCH] Explore possibilities re influence classes - make `agent` and `entity` derive from `influencer` (all three are slots) - add slot requirements: this is not really satisfactory, because linkml cannot populate slots from `equals_expression` before validation. - add dedicated examples, and also validate them --- .../data-distribution/AgentInfluence-std.json | 7 +++++++ .../data-distribution/AgentInfluence-std.yaml | 4 ++++ .../data-distribution/EntityInfluence-std.json | 7 +++++++ .../data-distribution/EntityInfluence-std.yaml | 4 ++++ src/linkml/schemas/data-distribution.yaml | 12 ++++++++++-- .../validation/AgentInfluence.valid.cfg.yaml | 9 +++++++++ .../validation/EntityInfluence.valid.cfg.yaml | 9 +++++++++ 7 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 src/examples/data-distribution/AgentInfluence-std.json create mode 100644 src/examples/data-distribution/AgentInfluence-std.yaml create mode 100644 src/examples/data-distribution/EntityInfluence-std.json create mode 100644 src/examples/data-distribution/EntityInfluence-std.yaml create mode 100644 tests/data-distribution-schema/validation/AgentInfluence.valid.cfg.yaml create mode 100644 tests/data-distribution-schema/validation/EntityInfluence.valid.cfg.yaml diff --git a/src/examples/data-distribution/AgentInfluence-std.json b/src/examples/data-distribution/AgentInfluence-std.json new file mode 100644 index 0000000..f49e157 --- /dev/null +++ b/src/examples/data-distribution/AgentInfluence-std.json @@ -0,0 +1,7 @@ +{ + "had_role": [ + "marcrel:aut" + ], + "agent": "https://orcid.org/0000-0001-6398-6370", + "@type": "AgentInfluence" +} diff --git a/src/examples/data-distribution/AgentInfluence-std.yaml b/src/examples/data-distribution/AgentInfluence-std.yaml new file mode 100644 index 0000000..05c44e0 --- /dev/null +++ b/src/examples/data-distribution/AgentInfluence-std.yaml @@ -0,0 +1,4 @@ +# Declare a person identified by an ORCID to have had the role of an author +agent: https://orcid.org/0000-0001-6398-6370 +had_role: + - marcrel:aut diff --git a/src/examples/data-distribution/EntityInfluence-std.json b/src/examples/data-distribution/EntityInfluence-std.json new file mode 100644 index 0000000..621b176 --- /dev/null +++ b/src/examples/data-distribution/EntityInfluence-std.json @@ -0,0 +1,7 @@ +{ + "had_role": [ + "dlco:is_about" + ], + "entity": "https://en.wikipedia.org/wiki/Vulcan_(Star_Trek)#Mind_melds", + "@type": "EntityInfluence" +} diff --git a/src/examples/data-distribution/EntityInfluence-std.yaml b/src/examples/data-distribution/EntityInfluence-std.yaml new file mode 100644 index 0000000..6bcf916 --- /dev/null +++ b/src/examples/data-distribution/EntityInfluence-std.yaml @@ -0,0 +1,4 @@ +# Declare the topic of a subject to be Vulcan mind melds +entity: https://en.wikipedia.org/wiki/Vulcan_(Star_Trek)#Mind_melds +had_role: + - dlco:is_about diff --git a/src/linkml/schemas/data-distribution.yaml b/src/linkml/schemas/data-distribution.yaml index c9cbd60..8fa9ae5 100644 --- a/src/linkml/schemas/data-distribution.yaml +++ b/src/linkml/schemas/data-distribution.yaml @@ -89,6 +89,7 @@ slots: agent: slot_uri: dlco:agent + is_a: influencer description: >- References an agent which influenced an entity. range: Agent @@ -218,6 +219,7 @@ slots: entity: slot_uri: dlco:entity + is_a: influencer description: >- References an entity which influenced an entity. range: Entity @@ -441,8 +443,6 @@ slots: range: string type: - #slot_uri: dlco:type - #slot_uri: http://www.w3.org/1999/02/22-rdf-syntax-ns#type slot_uri: RDF:type designates_type: true description: >- @@ -740,6 +740,12 @@ classes: slot_usage: had_role: multivalued: true + required: true + influencer: + # we cannot make it required. The equals_expression of, + # e.g. `AgentInfluence` does not kick in for value inference + # before validation errors out + #required: true exact_mappings: - prov:Influence @@ -753,6 +759,7 @@ classes: - agent slot_usage: agent: + required: true equals_expression: "{influencer}" todos: - Ideally this would be a structured_alias to `influencer`. However, this does not seem to work at all in the way that it is described. @@ -780,6 +787,7 @@ classes: - entity slot_usage: entity: + required: true equals_expression: "{influencer}" todos: - Ideally this would be a structured_alias to `influencer`. However, this does not seem to work at all in the way that it is described. diff --git a/tests/data-distribution-schema/validation/AgentInfluence.valid.cfg.yaml b/tests/data-distribution-schema/validation/AgentInfluence.valid.cfg.yaml new file mode 100644 index 0000000..6dfccb3 --- /dev/null +++ b/tests/data-distribution-schema/validation/AgentInfluence.valid.cfg.yaml @@ -0,0 +1,9 @@ +schema: src/linkml/schemas/data-distribution.yaml +target_class: AgentInfluence +data_sources: + - src/examples/data-distribution/AgentInfluence-std.yaml +plugins: + JsonschemaValidationPlugin: + closed: true + include_range_class_descendants: false + RecommendedSlotsPlugin: diff --git a/tests/data-distribution-schema/validation/EntityInfluence.valid.cfg.yaml b/tests/data-distribution-schema/validation/EntityInfluence.valid.cfg.yaml new file mode 100644 index 0000000..ee7061d --- /dev/null +++ b/tests/data-distribution-schema/validation/EntityInfluence.valid.cfg.yaml @@ -0,0 +1,9 @@ +schema: src/linkml/schemas/data-distribution.yaml +target_class: EntityInfluence +data_sources: + - src/examples/data-distribution/EntityInfluence-std.yaml +plugins: + JsonschemaValidationPlugin: + closed: true + include_range_class_descendants: false + RecommendedSlotsPlugin: