Skip to content

Commit

Permalink
feat: Process spatial, temporal and genre (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeboer committed Jun 21, 2024
1 parent 45139cc commit 80a1340
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
40 changes: 36 additions & 4 deletions shacl/register.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ reg:DatasetShape
reg:SchemaDateCreatedProperty,
reg:SchemaDatePublishedProperty,
reg:SchemaDateModifiedProperty,
reg:SchemaAlternateNameProperty ;
reg:SchemaAlternateNameProperty,
reg:SchemaKeywordsProperty,
reg:SchemaSpatialCoverageProperty,
reg:SchemaTemporalCoverageProperty,
reg:SchemaGenreProperty;

# TODO
# reg:SchemaVersionProperty, reg:SchemaManEntityOfPageProperty, reg:SchemaInLanguageProperty, reg:SchemaIsBasedOnUrlProperty, reg:SchemaCitationProperty,
# reg:SchemaGenreProperty, reg:SchemaKeywordsProperty, reg:SchemaSpatialCoverageProperty, reg:SchemaTemporalCoverageProperty, reg:SchemaIncludedInDataCatalogProperty,
# reg:SchemaIncludedInDataCatalogProperty,

.

Expand All @@ -66,7 +70,7 @@ reg:DistributionShape
sh:property
# Required properties
reg:DistributionContentUrlProperty,
reg:DistributionContentUrlIriProperty,
reg:DistributionContentUrlIriProperty,
reg:DistributionEncodingFormatProperty,
# Recommended properties
reg:SchemaDistributionNameProperty,
Expand Down Expand Up @@ -192,7 +196,7 @@ reg:SchemaDatasetProperty a sh:PropertyShape ;
sh:path schema:dataset ;
sh:class schema:Dataset ;
sh:minCount 1 ;
sh:node schema:DatasetShape ;
sh:node reg:DatasetShape ;
sh:name "Dataset(s) in de datacatalogus"@nl, "Dataset(s) in the data catalog"@en ;
sh:message "Een datacatalogus dient minimaal een dataset te bevatten"@nl, "A data catalog should contain at least one dataset"@en ;
sh:severity sh:Warning ;
Expand Down Expand Up @@ -334,6 +338,34 @@ reg:SchemaDistributionProperty a sh:PropertyShape ;
# which is confusing to users.
.

reg:SchemaKeywordsProperty a sh:PropertyShape ;
sh:path schema:keywords ;
sh:minCount 1 ;
sh:severity sh:Info ;
sh:message "Een datasetbeschrijving kan trefwoorden bevatten"@nl, "A dataset description may contain keywords"@en ;
.

reg:SchemaSpatialCoverageProperty a sh:PropertyShape ;
sh:path schema:spatialCoverage ;
sh:minCount 1 ;
sh:severity sh:Info ;
sh:message "Een datasetbeschrijving kan een gebiedsaanduidingen bevatten"@nl, "A dataset description may contain spatial coverage"@en ;
.

reg:SchemaTemporalCoverageProperty a sh:PropertyShape ;
sh:path schema:temporalCoverage ;
sh:minCount 1 ;
sh:severity sh:Info ;
sh:message "Een datasetbeschrijving kan tijdsaanduidingen bevatten"@nl, "A dataset description may contain temporal coverage"@en ;
.

reg:SchemaGenreProperty a sh:PropertyShape ;
sh:path schema:genre ;
sh:minCount 1 ;
sh:severity sh:Info ;
sh:message "Een datasetbeschrijving kan genres bevatten"@nl, "A dataset description may contain genres"@en ;
.

##
## DCAT
##
Expand Down
12 changes: 12 additions & 0 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const dateModified = 'dateModified';
const language = 'language';
const source = 'source';
const keyword = 'keyword';
const spatialCoverage = 'spatialCoverage';
const temporalCoverage = 'temporalCoverage';
const genre = 'genre';
const mainEntityOfPage = 'mainEntityOfPage';
const version = 'version';
const includedInDataCatalog = 'includedInDataCatalog';
Expand Down Expand Up @@ -74,6 +77,9 @@ export const constructQuery = `
dct:source ?${source} ;
dcat:keyword ?${keyword} ;
dcat:landingPage ?${mainEntityOfPage} ;
dct:spatial ?${spatialCoverage} ;
dct:temporal ?${temporalCoverage} ;
dct:type ?${genre} ;
owl:versionInfo ?${version} ;
dct:isPartOf ?${includedInDataCatalog} ;
dct:publisher ?${publisher} ;
Expand Down Expand Up @@ -151,6 +157,9 @@ export const constructQuery = `
OPTIONAL { ?${dataset} dct:language ?${language} }
OPTIONAL { ?${dataset} dct:source ?${source} }
OPTIONAL { ?${dataset} dcat:keyword ?${keyword} }
OPTIONAL { ?${dataset} dct:spatial ?${spatialCoverage} }
OPTIONAL { ?${dataset} dct:temporal ?${temporalCoverage} }
OPTIONAL { ?${dataset} dct:genre ?${genre} }
OPTIONAL { ?${dataset} owl:versionInfo ?${version} }
OPTIONAL { ?${dataset} dct:isPartOf ?${includedInDataCatalog} }
OPTIONAL { ?${dataset} dcat:landingPage ?${mainEntityOfPage} }
Expand Down Expand Up @@ -242,6 +251,9 @@ function schemaOrgQuery(prefix: string): string {
OPTIONAL { ?${dataset} ${prefix}:isBasedOn ?${source} }
OPTIONAL { ?${dataset} ${prefix}:isBasedOnUrl ?${source} }
OPTIONAL { ?${dataset} ${prefix}:keywords ?${keyword} }
OPTIONAL { ?${dataset} ${prefix}:spatialCoverage ?${spatialCoverage} }
OPTIONAL { ?${dataset} ${prefix}:temporalCoverage ?${temporalCoverage} }
OPTIONAL { ?${dataset} ${prefix}:genre ?${genre} }
OPTIONAL { ?${dataset} ${prefix}:version ?${version} }
OPTIONAL { ?${dataset} ${prefix}:includedInDataCatalog ?${includedInDataCatalog} }
OPTIONAL { ?${dataset} ${prefix}:mainEntityOfPage ?${mainEntityOfPage} }
Expand Down
5 changes: 5 additions & 0 deletions test/datasets/dataset-dcat-valid.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
}
],
"dct:language": ["nl-NL", "en-GB"],
"dct:spatial": {
"@id": "https://sws.geonames.org/2750405/"
},
"dct:temporal": "1939/1945",
"dct:type": "Interesting data",
"dcat:distribution": [
{
"@type": "dcat:Distribution",
Expand Down
5 changes: 5 additions & 0 deletions test/datasets/dataset-schema-org-valid.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@
"@language": "en"
},
"keywords": "alba amicorum",
"genre": "Interesting data",
"url": "https://www.kb.nl/bronnen-zoekwijzers/kb-collecties/moderne-handschriften-vanaf-ca-1550/alba-amicorum",
"identifier": "http://data.bibliotheken.nl/id/dataset/rise-alba",
"license": "http://creativecommons.org/publicdomain/zero/1.0/",
"inLanguage": ["nl-NL", "en-GB"],
"spatialCoverage": {
"@id": "https://sws.geonames.org/2750405/"
},
"temporalCoverage": "1939/1945",
"publisher": {
"@type": "Organization",
"@id": "https://example.com/publisher",
Expand Down
2 changes: 1 addition & 1 deletion test/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ describe('Fetch', () => {

expect(datasets).toHaveLength(1);
const dataset = datasets[0];
expect(dataset.size).toBe(31);

const dcatEquivalent = await dereference(
'test/datasets/dataset-dcat-valid.jsonld'
);
expect(dataset.size).toStrictEqual(dcatEquivalent.size);
expect(dataset.toCanonical()).toStrictEqual(dcatEquivalent.toCanonical());

expect(
Expand Down

0 comments on commit 80a1340

Please sign in to comment.