Retrieve all expressions titles in multiple languages.
By not using inference:
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
select distinct * where {
?w a cdm:work.
?expr cdm:expression_belongs_to_work ?w.
?expr cdm:expression_uses_language ?lang.
?expr cdm:expression_title ?title.
}
limit 5000
---
Give it a try at the CELLAR SPARQL endpoint (in PROD): click here
And by using inference:
DEFINE input:inference "cdm_rule_set"
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
select distinct * where {
?w a cdm:work.
?expr cdm:expression_belongs_to_work ?w.
?expr cdm:uses ?lang.
#?expr cdm:expression_uses_language ?lang.
?expr cdm:expression_title ?title.
}
limit 5000
---
Give it a try at the CELLAR SPARQL endpoint (in PROD): click here
Tips: try to avoid the inference when it is possible, because there is a cost behind.
search for expression titles in English
#DEFINE input:inference "cdm_rule_set"
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
select distinct * where {
?w a cdm:work.
?expr cdm:expression_belongs_to_work ?w.
#?expr cdm:uses ?lang.
?expr cdm:expression_uses_language <http://publications.europa.eu/resource/authority/language/ENG>.
?expr cdm:expression_title ?title.
}
limit 500
---
Give it a try at the CELLAR SPARQL endpoint (in PROD): click here
search for English title containing a specific term
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
select distinct * where {
?w a cdm:work.
?expr cdm:expression_belongs_to_work ?w.
?expr cdm:expression_uses_language <http://publications.europa.eu/resource/authority/language/ENG>.
?expr cdm:expression_title ?title.
FILTER ( regex ( ?title, "energy") )
}
limit 50
---
Give it a try at the CELLAR SPARQL endpoint (in PROD): click here
look deeper at the manifestion level
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
select distinct * where {
?w a cdm:work.
?expr cdm:expression_belongs_to_work ?w.
?expr cdm:expression_uses_language <http://publications.europa.eu/resource/authority/language/ENG>.
?expr cdm:expression_title ?title.
FILTER ( regex ( ?title, "energy") )
?man cdm:manifestation_manifests_expression ?expr.
}
limit 50
---
Give it a try at the CELLAR SPARQL endpoint (in PROD): click here
look deeper at the item level
prefix cdm: <http://publications.europa.eu/ontology/cdm#>
select distinct * where {
?w a cdm:work.
?expr cdm:expression_belongs_to_work ?w.
?expr cdm:expression_uses_language <http://publications.europa.eu/resource/authority/language/ENG>.
?expr cdm:expression_title ?title.
FILTER ( regex ( ?title, "energy") )
?man cdm:manifestation_manifests_expression ?expr.
?item cdm:item_belongs_to_manifestation ?man.
}
limit 50
---
Give it a try at the CELLAR SPARQL endpoint (in PROD): click here
If the return time of the SPARQL endpoint increases significantly, one possible optimization is to split the previous query into two sub queries at the level of expression/manifesation, i.e., we first retrieve top N expressions/manifestations and then run several sub-queries to retrieve the corresponding manifestations/items. The same mechanism can be applied for other complex SPARQL queries.
On the other hand, the previous query retrieves the documents containing the term "energy". If the SPARQL endpoint finds top 50 documents, it will return very quickly, otherwise for example, if we look for the term "bitcoin" in the big Semantic Web repository, since the topic is emergent, it will take more time to browse the entire repository.
You can compare the performance of the two previous queries here: query 1 (energy) vs query 2 (bitcoin)
Observation: the response time of query 1 is faster than query 2 even after optimisation.
Lessons learnt: we figure out that the legislative laws published at the European institutions about 'energy' are more popular then the ones about 'bitcoin'.