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

Add check to look for IRIs in label #542

Merged
merged 2 commits into from
Feb 11, 2022
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
2 changes: 1 addition & 1 deletion odk/odk.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class ReportConfig(JsonSchemaMixin):
release_reports : bool = False
""" If true, release reports are added as assets to the release (top level directory, reports directory)"""

custom_sparql_checks : Optional[List[str]] = field(default_factory=lambda: ['equivalent-classes', 'owldef-self-reference', 'iri-range'])
custom_sparql_checks : Optional[List[str]] = field(default_factory=lambda: ['equivalent-classes', 'owldef-self-reference', 'iri-range', 'label-with-iri'])
"""Chose which additional sparql checks yoy want to run. The related sparql query must be named CHECKNAME-violation.sparql, and be placed in the src/sparql directory"""

custom_sparql_exports : Optional[List[str]] = field(default_factory=lambda: ['basic-report', 'class-count-by-prefix', 'edges', 'xrefs', 'obsoletes', 'synonyms'])
Expand Down
12 changes: 12 additions & 0 deletions template/_dynamic_files.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,18 @@ WHERE {
}
{% endif %}

{%- if project.robot_report.custom_sparql_checks is not defined or 'label-with-iri' in project.robot_report.custom_sparql_checks %}
^^^ src/sparql/label-with-iri-violation.sparql
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?term ?value
WHERE {
?term rdfs:label ?value .
FILTER (REGEX(?value, "http[s]?[:]"))
FILTER (isIRI(?term) && (REGEX(str(?term), UCASE("{{ project.id }}_")){% if project.namespaces %}{% for ns in project.namespaces %} || REGEX(str(?term), "{{ ns }}"){% endfor %}{% endif %}))
}
{% endif %}

{%- if project.components is defined %}
{%- for component in project.components.products %}
^^^ src/ontology/components/{{ component.filename }}
Expand Down