Last active
March 6, 2016 02:29
-
-
Save blake-regalia/d7eae6e7ab26dc92d5b1 to your computer and use it in GitHub Desktop.
Demonstration of the Pattern Rewriter feature in the VOLT framework
This file contains 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
prefix volt: <http://volt-name.space/ontology/> | |
prefix input: <http://volt-name.space/vocab/input#> | |
prefix output: <http://volt-name.space/vocab/input#> | |
prefix dbp: <http://dbpedia.org/property/> | |
# SPARQL query as it appears when sent to VOLT proxy | |
select (sum(?population) as ?totalPopulation) where { | |
?matcher volt:firstMatch [ | |
input:onVariable "?p"^^volt:Variable ; | |
input:useValuesFrom (dbp:population dbp:populationTotal) ; | |
input:sampleFromVariables ("?population"^^volt:Variable) | |
] . | |
graph ?matcher { | |
?s ?p ?population . | |
filter(isNumeric(?population)) | |
} | |
} | |
# Actual expanded query that gets issued to the SPARQL endpoint | |
select (sum(?population) as ?totalPopulation) { | |
{ select ?s ?p (sample(?_sample_population) as ?population) { | |
{ | |
?s ?p ?_sample_value . | |
filter(isNumeric(?_sample_value)) | |
values ?p { dbp:population } | |
} union { | |
?place ?p ?_sample_value . | |
filter(isNumeric(?_sample_value)) | |
values ?p { dbp:populationTotal } | |
filter not exists { | |
?place dbp:population ?_0_value . | |
filter(isNumeric(?_0_value)) | |
} | |
} | |
} group by ?s } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment