5 Query - kylebot0/functional-programming GitHub Wiki
The query i used is still in development but for now i have this.
Version 1.0:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?materialLabel (COUNT(?materialBroad3) AS ?countMaterialLabel)
WHERE {
?cho dct:medium ?medium .
?medium skos:broader ?materialBroad .
?materialBroad skos:broader ?materialBroad2 .
?materialBroad2 skos:broader ?materialBroad3 .
?materialBroad3 skos:prefLabel ?materialLabel .
#FILTER(REGEX (?materialLabel, "Materiaal en techniek")) .
}ORDER BY DESC(?countMaterialLabel)
LIMIT 10000
As i needed to search the thesaurus i had to make a variable called medium. I wanted to select all the most used materials in the highest level first. So that requires a couple broader searches. Next i needed to count all the different or the same materials. that's why i used the:
(COUNT(?materialBroad3) AS ?countMaterialLabel)
The data it collects is :
data: {
"materialLabel": string,
"materialLabel2": string,
"materialLabel3": string,
"materialLabel4": string,
}
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?materialNarrow3 ?materialLabel (COUNT(?materialNarrow3) AS ?countMaterialLabel)
WHERE {
?cho dct:medium ?medium .
?medium skos:broader ?materialBroad .
?materialBroad skos:broader ?materialBroad2 .
?materialBroad2 skos:broader ?materialBroad3 .
#?materialBroad3 skos:prefLabel ?materialLabel .
#VALUES ?term {<https://hdl.handle.net/20.500.11840/termmaster26637>}
#?term skos:narrower ?materialNarrow .
#?materialNarrow skos:prefLabel ?materialLabel .
#FILTER(REGEX (?materialLabel, "Materiaal en techniek")) .
VALUES ?term2 {<https://hdl.handle.net/20.500.11840/termmaster26637>}
?term2 skos:narrower ?materialNarrow .
?materialNarrow skos:narrower ?materialNarrow2 .
?materialNarrow2 skos:narrower ?materialNarrow3 .
?materialNarrow3 skos:prefLabel ?materialLabel .
}ORDER BY DESC(?countMaterialLabel)
LIMIT 10000
This collects the types of wood, the only problem i have is that the amount at which it counts the wood isn't right. It always gives me the same number: 1333236
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?medium ?materialLabel (COUNT(?materialLabel) AS ?countMaterialLabel)
WHERE {
?cho dct:medium ?medium .
?medium skos:prefLabel ?materialLabel .
}ORDER BY DESC(?countMaterialLabel)
LIMIT 25
This query is one of the latest versions, it collects the most used broad terms, like wood, fototechniques etc.
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?materialNarrow ?materialLabel (COUNT(?materialLabel) AS ?countMaterialLabel)
WHERE {
VALUES ?term {<${uri}>}
?term skos:narrower ?materialNarrow .
#?materialNarrow skos:narrower ?materialNarrow2 .
?materialNarrow skos:prefLabel ?materialLabel .
}ORDER BY DESC(?countMaterialLabel)
LIMIT 25
This is the final query, it does however need the previous query to collect data from the broader terms. Then it takes as an input the term of the broad query and then narrows it down to a child of the term.