Difference between revisions of "Sparql endpoint"
Jump to navigation
Jump to search
Line 79: | Line 79: | ||
FILTER (?startDate >= "2010-01-01"^^xsd:date && ?endDate < "2017-01-01"^^xsd:date). | FILTER (?startDate >= "2010-01-01"^^xsd:date && ?endDate < "2017-01-01"^^xsd:date). | ||
} ORDER BY DESC(?startDate) LIMIT 10 | } ORDER BY DESC(?startDate) LIMIT 10 | ||
+ | </pre> | ||
+ | |||
+ | ===== Query 4, Which period of year have had the most number of events organized for a specific field or topic ===== | ||
+ | <pre> | ||
+ | PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | ||
+ | PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
+ | PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | ||
+ | PREFIX property: <http://openresearch.org/Special:URIResolver/Property-3A> | ||
+ | PREFIX category: <http://openresearch.org/Special:URIResolver/Category-3A> | ||
+ | PREFIX icaltzd: <https://www.w3.org/2002/12/cal/icaltzd#> | ||
+ | |||
+ | |||
+ | SELECT ?month (count(?e) as ?numEvents) WHERE | ||
+ | { | ||
+ | ?e rdfs:label ?event. | ||
+ | ?e icaltzd:dtend ?endDate. | ||
+ | ?e icaltzd:dtstart ?startDate. | ||
+ | ?e a category:Semantic_Web. | ||
+ | Filter (datatype(?endDate) != xsd:double && datatype(?startDate) != xsd:double) | ||
+ | FILTER (?startDate >= "2016-01-01"^^xsd:date && ?endDate < "2017-01-01"^^xsd:date). | ||
+ | VALUES ?month {1 2 3 4 5 6 7 8 9 10 11 12} | ||
+ | FILTER ( month(?startDate) <= ?month && ?month <= month(?endDate) ) | ||
+ | } GROUP BY ?month | ||
</pre> | </pre> |
Revision as of 17:35, 19 December 2016
Sparql endpoint
The sparql endpoint for the RDF dataset of OpenResearch is in sparql.
The following contains some sparql query examples
Query 1, find events which have country location, city location, start date, end date, and home page
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX swivt: <http://semantic-mediawiki.org/swivt/1.0#> PREFIX property: <http://openresearch.org/Special:URIResolver/Property-3A> PREFIX category: <http://openresearch.org/Special:URIResolver/Category-3A> PREFIX wiki: <http://openresearch.org/Special:URIResolver/> PREFIX icaltzd: <https://www.w3.org/2002/12/cal/icaltzd#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?event ?endDate ?startDate ?city ?country ?wikipage ?homepage WHERE { ?e property:Has_location_country category:Germany. ?e rdfs:label ?event. ?e property:Has_location_city ?city. ?e property:Has_location_country ?country. ?e icaltzd:dtend ?endDate. ?e icaltzd:dtstart ?startDate. ?e foaf:homepage ?homepage. ?e swivt:page ?wikipage. } ORDER BY DESC(?startDate) LIMIT 100
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX swivt: <http://semantic-mediawiki.org/swivt/1.0#> PREFIX property: <http://openresearch.org/Special:URIResolver/Property-3A> PREFIX category: <http://openresearch.org/Special:URIResolver/Category-3A> PREFIX wiki: <http://openresearch.org/Special:URIResolver/> PREFIX site: <http://openresearch.org/Special:ExportRDF/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX icaltzd: <https://www.w3.org/2002/12/cal/icaltzd#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?event ?endDate ?startDate ?city ?country ?wikipage ?acceptanceRate ?continent WHERE { ?e rdfs:label ?event. ?e property:Has_location_country ?country. ?country rdfs:subClassOf ?partContinent. ?partContinent rdfs:subClassOf ?continent. ?continent rdfs:isDefinedBy site:Category:Europe. ?e a category:Semantic_Web. ?e icaltzd:dtstart ?startDate. ?e icaltzd:dtend ?endDate. ?e property:Acceptance_rate ?acceptanceRate. ?e property:Has_location_city ?city. ?e swivt:page ?wikipage. FILTER (?acceptanceRate < 25.0 && ?startDate >= "2016-01-01"^^xsd:date && ?endDate < "2017-01-01"^^xsd:date). } ORDER BY DESC(?startDate) LIMIT 100
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX swivt: <http://semantic-mediawiki.org/swivt/1.0#> PREFIX urir: <http://openresearch.org/Special:URIResolver/> PREFIX property: <http://openresearch.org/Special:URIResolver/Property-3A> PREFIX category: <http://openresearch.org/Special:URIResolver/Category-3A> PREFIX wiki: <http://openresearch.org/Special:URIResolver/> PREFIX site: <http://openresearch.org/Special:ExportRDF/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX icaltzd: <https://www.w3.org/2002/12/cal/icaltzd#> SELECT ?event ?endDate ?startDate ?pcMember ?geMember WHERE { ?e rdfs:label ?event. ?e property:Has_PC_member ?pcMember. ?e property:Has_general_chair ?geMember. ?e a category:Semantic_Web. ?e icaltzd:dtstart ?startDate. ?e icaltzd:dtend ?endDate. minus {?e property:Has_PC_member urir:Some_person.} FILTER (?startDate >= "2010-01-01"^^xsd:date && ?endDate < "2017-01-01"^^xsd:date). } ORDER BY DESC(?startDate) LIMIT 10
Query 4, Which period of year have had the most number of events organized for a specific field or topic
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX property: <http://openresearch.org/Special:URIResolver/Property-3A> PREFIX category: <http://openresearch.org/Special:URIResolver/Category-3A> PREFIX icaltzd: <https://www.w3.org/2002/12/cal/icaltzd#> SELECT ?month (count(?e) as ?numEvents) WHERE { ?e rdfs:label ?event. ?e icaltzd:dtend ?endDate. ?e icaltzd:dtstart ?startDate. ?e a category:Semantic_Web. Filter (datatype(?endDate) != xsd:double && datatype(?startDate) != xsd:double) FILTER (?startDate >= "2016-01-01"^^xsd:date && ?endDate < "2017-01-01"^^xsd:date). VALUES ?month {1 2 3 4 5 6 7 8 9 10 11 12} FILTER ( month(?startDate) <= ?month && ?month <= month(?endDate) ) } GROUP BY ?month