Skip to content

Commit

Permalink
feat: Create an ontology graph that combines triples from frequency, …
Browse files Browse the repository at this point in the history
…theme, licenses, formats and mime types graphs
  • Loading branch information
kovalch committed Mar 14, 2024
1 parent 27983aa commit 6766dff
Show file tree
Hide file tree
Showing 7 changed files with 9,037 additions and 12 deletions.
34 changes: 33 additions & 1 deletion ckan_pkg_checker/checkers/shacl_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from collections import namedtuple

import pandas as pd
from rdflib import Graph

from ckan_pkg_checker.checkers.checker_interface import CheckerInterface
from ckan_pkg_checker.utils import rdf_utils, utils
Expand Down Expand Up @@ -32,9 +33,40 @@ def __init__(self, rundir, config, siteurl):
frequency_file = utils.get_config(
config, "shaclchecker", "frequency_file", required=True
)
theme_file = utils.get_config(
config, "shaclchecker", "theme_file", required=True
)
licenses_file = utils.get_config(
config, "shaclchecker", "licenses_file", required=True
)
formats_file = utils.get_config(
config, "shaclchecker", "formats_file", required=True
)
mime_types_file = utils.get_config(
config, "shaclchecker", "mime_types_file", required=True
)
self._prepare_csv_file()
self.shacl_graph = rdf_utils.parse_rdf_graph_from_url(file=shaclfile, bind=True)
self.ont_graph = rdf_utils.parse_rdf_graph_from_url(file=frequency_file)

# Load and merge ontology graphs into a single RDF graph
frequency_graph = rdf_utils.parse_rdf_graph_from_url(file=frequency_file)
theme_graph = rdf_utils.parse_rdf_graph_from_url(file=theme_file)
licenses_graph = rdf_utils.parse_rdf_graph_from_url(file=licenses_file)
formats_graph = rdf_utils.parse_rdf_graph_from_url(file=formats_file)
mime_types_graph = rdf_utils.parse_rdf_graph_from_url(file=mime_types_file)

self.ont_graph = Graph()
ont_graphs_list = [
frequency_graph,
theme_graph,
licenses_graph,
formats_graph,
mime_types_graph,
]
triples_to_add = [triple for graph in ont_graphs_list for triple in graph]

for triple in triples_to_add:
self.ont_graph.add(triple)

def _prepare_csv_file(self):
self.csv_fieldnames = [
Expand Down
4 changes: 4 additions & 0 deletions config.ini.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ statfile = linkstatistics.csv
# shaclchecker input and output files
csvfile = shaclchecker.csv
frequency_file = /home/liip/ogdch_checker/frequency-eu.ttl
theme_file = /home/liip/ogdch_checker/theme-eu.ttl
licenses_file = /home/liip/ogdch_checker/licenses-dcat-ap-ch.ttl
formats_file = /home/liip/ogdch_checker/formats-eu.ttl
mime_types_file = /home/liip/ogdch_checker/mime-types.ttl
statfile = shaclstatistics.csv
shacl_file = /home/liip/ogdch_checker/ogdch.shacl.ttl

Expand Down
845 changes: 845 additions & 0 deletions formats-eu.ttl

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions licenses-dcat-ap-ch.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix dc11: <http://purl.org/dc/elements/1.1/> .
@prefix skosxl: <http://www.w3.org/2008/05/skos-xl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<http://dcat-ap.ch/vocabulary/licenses>
a owl:Ontology, skos:ConceptScheme ;
owl:versionInfo "202100623" ;
owl:versionIRI <http://dcat-ap.ch/vocabulary/licenses/20210623/> ;
rdfs:comment "Liste der Lizenzen, die im Feld dct:license einer DCAT-AP CH-konformen dcat:distribution für die Zulieferung an opendata.swiss erlaubt sind."@de ,
"List of licenses that are allowed in the field dct:license for delivering a dcat:Distribution in a way that conforms to DCAT-AP CH"@en ;
rdfs:label "Liste der Lizenzen"@de, "List of Licenses"@en;
skos:prefLabel "Liste der Lizenzen"@de ;
dct:identifier "http://dcat-ap.ch/vocabulary/licenses" .

<http://dcat-ap.ch/vocabulary/licenses/terms_open>
skos:inScheme <http://dcat-ap.ch/vocabulary/licenses> ;
skos:topConceptOf <http://dcat-ap.ch/vocabulary/licenses> ;
a skos:Concept ;
skos:prefLabel "Opendata OPEN: Open use."@en,
"Opendata OPEN: Utilisation libre."@fr,
"Opendata OPEN: Freie Nutzung."@de,
"Opendata OPEN: Libero utilizzo."@it ;
skos:altLabel "Freie Nutzung"@de,
"Utilisation libre"@fr ;
skosxl:prefLabel [
a skosxl:Label ;
skosxl:literalForm "NonCommercialAllowed-CommercialAllowed-ReferenceNotRequired"@en ;
rdfs:label "NonCommercialAllowed-CommercialAllowed-ReferenceNotRequired"@en
] ;
foaf:homepage <https://opendata.swiss/terms-of-use/#terms_open> .

<http://dcat-ap.ch/vocabulary/licenses/terms_by>
skos:inScheme <http://dcat-ap.ch/vocabulary/licenses> ;
skos:topConceptOf <http://dcat-ap.ch/vocabulary/licenses> ;
a skos:Concept ;
skos:prefLabel "Opendata BY: Open use. Must provide the source."@en,
"Opendata BY: Utilisation libre. Obligation d’indiquer la source."@fr,
"Opendata BY: Freie Nutzung. Quellenangabe ist Pflicht."@de,
"Opendata BY: Libero utilizzo. Indicazione della fonte obbligatoria. Utilizzo a fini commerciali ammesso soltanto previo consenso del titolare dei dati"@it ;
skos:altLabel "Freie Nutzung. Quellenangabe ist Pflicht."@de,
"Utilisation libre. Obligation d’indiquer la source."@fr ;
skosxl:prefLabel [
a skosxl:Label ;
skosxl:literalForm "NonCommercialAllowed-CommercialAllowed-ReferenceRequired"@en ;
rdfs:label "NonCommercialAllowed-CommercialAllowed-ReferenceRequired"@de
] ;
foaf:homepage <https://opendata.swiss/en/terms-of-use/#terms_by> .

<http://dcat-ap.ch/vocabulary/licenses/terms_ask>
skos:inScheme <http://dcat-ap.ch/vocabulary/licenses> ;
skos:topConceptOf <http://dcat-ap.ch/vocabulary/licenses> ;
a skos:Concept ;
skos:prefLabel "Opendata ASK: Open use. Use for commercial purposes requires permission of the data owner."@en,
"Opendata ASK: Utilisation libre. Utilisation à des fins commerciales uniquement avec l’autorisation du fournisseur des données."@fr,
"Opendata ASK: Freie Nutzung. Kommerzielle Nutzung nur mit Bewilligung des Datenlieferanten zulässig."@de,
"Opendata ASK: Libero utilizzo. Utilizzo a fini commerciali ammesso soltanto previo consenso del titolare dei dati."@it ;
skos:altLabel "Freie Nutzung. Kommerzielle Nutzung nur mit Bewilligung des Datenlieferanten zulässig."@de,
"Utilisation libre. Utilisation à des fins commerciales uniquement avec l’autorisation du fournisseur des données."@fr ;
skosxl:prefLabel [
a skosxl:Label ;
skosxl:literalForm "NonCommercialAllowed-CommercialWithPermission-ReferenceNotRequired"@en ;
rdfs:label "NonCommercialAllowed-CommercialWithPermission-ReferenceNotRequired"@de
] ;
foaf:homepage <https://opendata.swiss/en/terms-of-use/#terms_ask> .

<http://dcat-ap.ch/vocabulary/licenses/terms_by_ask>
skos:inScheme <http://dcat-ap.ch/vocabulary/licenses> ;
skos:topConceptOf <http://dcat-ap.ch/vocabulary/licenses> ;
a skos:Concept ;
skos:prefLabel "Opendata BY ASK: Open use. Must provide the source. Use for commercial purposes requires permission of the data owner."@en,
"Opendata BY ASK: Utilisation libre. Obligation d’indiquer la source. Utilisation commerciale uniquement avec l’autorisation du fournisseur des données."@fr,
"Opendata BY ASK: Freie Nutzung. Quellenangabe ist Pflicht. Kommerzielle Nutzung nur mit Bewilligung des Datenlieferanten zulässig."@de,
"Opendata BY ASK: Libero utilizzo. Indicazione della fonte obbligatoria. Utilizzo a fini commerciali ammesso soltanto previo consenso del titolare dei dati."@it ;
skos:altLabel "Freie Nutzung. Quellenangabe ist Pflicht. Kommerzielle Nutzung nur mit Bewilligung des Datenlieferanten zulässig."@de,
"Utilisation libre. Obligation d’indiquer la source. Utilisation commerciale uniquement avec l’autorisation du fournisseur des données."@fr ;
skosxl:prefLabel [
a skosxl:Label ;
skosxl:literalForm "NonCommercialAllowed-CommercialWithPermission-ReferenceRequired"@en ;
rdfs:label "NonCommercialAllowed-CommercialWithPermission-ReferenceRequired"@de
] ;
foaf:homepage <https://opendata.swiss/en/terms-of-use/#terms_by_ask> .
Loading

0 comments on commit 6766dff

Please sign in to comment.