domenica 13 novembre 2011

Esempi SPARQL

Abstracts of movies starring Tom Cruise, released before 1999

SELECT ?subject ?label ?released ?abstract WHERE {
?subject rdf:type <http://dbpedia.org/ontology/Film>.
?subject dbpedia2:starring <http://dbpedia.org/resource/Tom_Cruise>.
?subject rdfs:comment ?abstract.
?subject rdfs:label ?label.
FILTER(lang(?abstract) = "en" && lang(?label) = "en").
?subject <http://dbpedia.org/ontology/releaseDate> ?released.
FILTER(xsd:date(?released) < "2000-01-01"^^xsd:date).
} ORDER BY ?released
LIMIT 20

----
The official websites of companies with more than 50000 employees

SELECT DISTINCT ?subject
                ?employees
                ?homepage
  WHERE
    {
      ?subject  rdf:type               <http://dbpedia.org/class/yago/Company108058098>  .
      ?subject  dbpedia2:numEmployees  ?employees
        FILTER  ( xsd:integer(?employees) >= 50000 )                                     .
      ?subject  foaf:homepage          ?homepage                                         .
    }
  ORDER BY  DESC(xsd:integer(?employees))
  LIMIT  20
  ----

Cities with more than 2 million habitants

SELECT ?subject ?population WHERE {
?subject rdf:type <http://dbpedia.org/ontology/City>.
?subject <http://dbpedia.org/ontology/populationUrban> ?population.
FILTER (xsd:integer(?population) > 2000000)
}
ORDER BY DESC(xsd:integer(?population))
LIMIT 20

---------------

Querying the Infobox Ontology

SELECT *
  WHERE
    {
      ?e <http://dbpedia.org/ontology/series>         <http://dbpedia.org/resource/The_Sopranos>  .
      ?e <http://dbpedia.org/ontology/releaseDate>    ?date                                       .
      ?e <http://dbpedia.org/ontology/episodeNumber>  ?number                                     .
      ?e <http://dbpedia.org/ontology/seasonNumber>   ?season
    }
  ORDER BY DESC(?date)
 
-----

Nessun commento:

Posta un commento