-
Notifications
You must be signed in to change notification settings - Fork 0
Add seven SPARQL integrity checks and fix what they found #9
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
Open
hoodcm
wants to merge
2
commits into
main
Choose a base branch
from
add-linting-rules
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| <<<<<<< HEAD | ||
| # OS | ||
| .DS_Store | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,8 @@ | ||
| ERROR file:./tests/sparql/robot/leading_trailing_multi_whitespace.rq | ||
| ERROR file:./tests/sparql/robot/leading_trailing_multi_whitespace.rq | ||
| ERROR file:./tests/sparql/robot/empty_annotation_value.rq | ||
| ERROR file:./tests/sparql/robot/mismatched_radlexid.rq | ||
| ERROR file:./tests/sparql/robot/literal_replaced_by_value.rq | ||
| ERROR file:./tests/sparql/robot/dangling_replaced_by_target.rq | ||
| ERROR file:./tests/sparql/robot/live_class_with_replaced_by.rq | ||
| ERROR file:./tests/sparql/robot/live_class_with_preferred_name_for_obsolete.rq | ||
| ERROR file:./tests/sparql/robot/live_class_under_obsolete_parent.rq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| PREFIX owl: <http://www.w3.org/2002/07/owl#> | ||
| PREFIX rid: <http://www.radlex.org/RID/> | ||
|
|
||
| # | ||
| # Part of the RadLex ontology SPARQL test suite. Bindings to this query represent violations of the test. | ||
| # | ||
| # Test that every rid:Replaced_by pointer aims at a class declared in RadLex. A pointer to an undeclared IRI, | ||
| # such as a mistyped RID, cannot be followed. A pointer to a class that is itself obsolete is allowed: the | ||
| # chain records the retirement history, and a consumer can follow it to the end. | ||
| # | ||
| # VIOLATIONS will be bindings that have, on ?entity, ?property, and ?value respectively: | ||
| # - The obsolete class carrying the pointer. | ||
| # - rid:Replaced_by. | ||
| # - The undeclared target IRI. | ||
| # | ||
| SELECT ?entity ?property ?value | ||
| WHERE { | ||
| BIND(rid:Replaced_by AS ?property) | ||
| ?entity ?property ?value . | ||
| FILTER(isIRI(?value)) | ||
| FILTER NOT EXISTS { ?value a owl:Class } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
| PREFIX owl: <http://www.w3.org/2002/07/owl#> | ||
|
|
||
| # | ||
| # Part of the RadLex ontology SPARQL test suite. Bindings to this query represent violations of the test. | ||
| # | ||
| # Test that no annotation assertion has an empty or whitespace-only value. An empty assertion falsely signals | ||
| # that the field is populated. Every declared owl:AnnotationProperty is covered, plus rdfs:label, which is a | ||
| # built-in and therefore not declared. | ||
| # | ||
| # VIOLATIONS will be bindings that have, on ?entity, ?property, and ?value respectively: | ||
| # - The entity carrying the empty assertion. | ||
| # - The annotation property. | ||
| # - The empty or whitespace value. | ||
| # | ||
| SELECT ?entity ?property ?value | ||
| WHERE { | ||
| { ?property a owl:AnnotationProperty } UNION { BIND(rdfs:label AS ?property) } | ||
| ?entity ?property ?value . | ||
| FILTER(isLiteral(?value)) | ||
| FILTER(REGEX(STR(?value), "^\\s*$")) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| PREFIX rid: <http://www.radlex.org/RID/> | ||
|
|
||
| # | ||
| # Part of the RadLex ontology SPARQL test suite. Bindings to this query represent violations of the test. | ||
| # | ||
| # Test that every rid:Replaced_by value is an IRI reference to another class, not a string literal such as | ||
| # "RID11030". A literal cannot be followed by tooling that walks obsolete terms to their replacements. | ||
| # | ||
| # VIOLATIONS will be bindings that have, on ?entity, ?property, and ?value respectively: | ||
| # - The obsolete class carrying the pointer. | ||
| # - rid:Replaced_by. | ||
| # - The literal value that should have been an IRI. | ||
| # | ||
| SELECT ?entity ?property ?value | ||
| WHERE { | ||
| BIND(rid:Replaced_by AS ?property) | ||
| ?entity ?property ?value . | ||
| FILTER(isLiteral(?value)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
| PREFIX rid: <http://www.radlex.org/RID/> | ||
|
|
||
| # | ||
| # Part of the RadLex ontology SPARQL test suite. Bindings to this query represent violations of the test. | ||
| # | ||
| # Test that no class is filed under an obsolete class without itself being marked obsolete. An obsolete class | ||
| # is one filed, directly or through another obsolete class, under RID15849 ("Obsolete RadLex Term"). Filing | ||
| # makes every descendant obsolete, so a live class left under a class being retired is retired silently. | ||
| # rid:Preferred_Name_for_Obsolete is the per-class mark that the retirement was intended. RID15849 itself is | ||
| # not an obsolete parent, since obsolete classes are meant to hang under it. | ||
| # | ||
| # VIOLATIONS will be bindings that have, on ?entity, ?property, and ?value respectively: | ||
| # - The class that was never marked obsolete. | ||
| # - rdfs:subClassOf. | ||
| # - The obsolete parent. | ||
| # | ||
| SELECT ?entity ?property ?value | ||
| WHERE { | ||
| BIND(rdfs:subClassOf AS ?property) | ||
| ?entity ?property ?value . | ||
| ?value rdfs:subClassOf+ rid:RID15849 . | ||
| FILTER NOT EXISTS { ?entity rid:Preferred_Name_for_Obsolete ?_name } | ||
| } |
22 changes: 22 additions & 0 deletions
22
tests/sparql/robot/live_class_with_preferred_name_for_obsolete.rq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
| PREFIX rid: <http://www.radlex.org/RID/> | ||
|
|
||
| # | ||
| # Part of the RadLex ontology SPARQL test suite. Bindings to this query represent violations of the test. | ||
| # | ||
| # Test that only obsolete classes carry rid:Preferred_Name_for_Obsolete. An obsolete class is one filed, | ||
| # directly or through another obsolete class, under RID15849 ("Obsolete RadLex Term"). A live class carrying | ||
| # the property was made obsolete in name but never filed under RID15849, so tools that exclude RID15849's subclasses | ||
| # still offer it as a live term. | ||
| # | ||
| # VIOLATIONS will be bindings that have, on ?entity, ?property, and ?value respectively: | ||
| # - The live class carrying the property. | ||
| # - rid:Preferred_Name_for_Obsolete. | ||
| # - The obsolete name. | ||
| # | ||
| SELECT ?entity ?property ?value | ||
| WHERE { | ||
| BIND(rid:Preferred_Name_for_Obsolete AS ?property) | ||
| ?entity ?property ?value . | ||
| FILTER NOT EXISTS { ?entity rdfs:subClassOf+ rid:RID15849 } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
| PREFIX rid: <http://www.radlex.org/RID/> | ||
|
|
||
| # | ||
| # Part of the RadLex ontology SPARQL test suite. Bindings to this query represent violations of the test. | ||
| # | ||
| # Test that only obsolete classes carry rid:Replaced_by. An obsolete class is one filed, directly or through | ||
| # another obsolete class, under RID15849 ("Obsolete RadLex Term"). A live class with a replacement pointer is | ||
| # contradictory: either the class was never filed as obsolete or the pointer is stray. | ||
| # | ||
| # VIOLATIONS will be bindings that have, on ?entity, ?property, and ?value respectively: | ||
| # - The live class carrying the pointer. | ||
| # - rid:Replaced_by. | ||
| # - The pointer's target. | ||
| # | ||
| SELECT ?entity ?property ?value | ||
| WHERE { | ||
| BIND(rid:Replaced_by AS ?property) | ||
| ?entity ?property ?value . | ||
| FILTER NOT EXISTS { ?entity rdfs:subClassOf+ rid:RID15849 } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
| PREFIX owl: <http://www.w3.org/2002/07/owl#> | ||
| PREFIX rid: <http://www.radlex.org/RID/> | ||
|
|
||
| # | ||
| # Part of the RadLex ontology SPARQL test suite. Bindings to this query represent violations of the test. | ||
| # | ||
| # Test that a class's rid:RadLexID restates the local name of its own IRI. The ID is redundant with the IRI by | ||
| # design, so any disagreement is a copy or typing error that desynchronises ID-keyed consumers from IRI-keyed | ||
| # ones. A class in the RID namespace with no rid:RadLexID at all is also a violation. | ||
| # | ||
| # Scope: classes whose IRI local name has the form RID<digits>. | ||
| # | ||
| # VIOLATIONS will be bindings that have, on ?entity, ?property, and ?value respectively: | ||
| # - The class whose ID disagrees with (or is missing from) its IRI. | ||
| # - rid:RadLexID. | ||
| # - The ID value found, or the empty string when the class carries none. | ||
| # | ||
| SELECT ?entity ?property ?value | ||
| WHERE { | ||
| ?entity a owl:Class . | ||
| FILTER(REGEX(STR(?entity), "^http://www\\.radlex\\.org/RID/RID[0-9]+$")) | ||
| BIND(rid:RadLexID AS ?property) | ||
| BIND(REPLACE(STR(?entity), "^http://www\\.radlex\\.org/RID/", "") AS ?expected) | ||
| OPTIONAL { ?entity rid:RadLexID ?id } | ||
| BIND(COALESCE(STR(?id), "") AS ?value) | ||
| FILTER(?value != ?expected) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. rdfs:subPropertyOf is reflexive, so with RDFS entailments, the '*' would not be necessary - but ROBOT does not compute those entailments when it runs these testing queries.