Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SPARQL 4.10 KB | None | 0 0
  1. 1 - Retorne todos os indivíduos do tema (Astronauta)
  2. PREFIX dbo: <http://dbpedia.org/ontology/>
  3. SELECT DISTINCT ?Astronaut ?Astronaut_Label WHERE {
  4.     ?Astronaut rdf:type dbo:Astronaut.
  5.     ?Astronaut rdfs:label ?Astronaut_Label
  6.     FILTER((LANGMATCHES(LANG(?Astronaut_Label), "en")) && (LANGMATCHES(LANG(?Astronaut_Label), "en")))
  7. }
  8.  
  9. 2 - Retorne o número de indivíduos do tema (Astronauta)
  10. PREFIX dbo: <http://dbpedia.org/ontology/>
  11. SELECT COUNT(*) {
  12.     SELECT DISTINCT ?Astronaut ?Astronaut_Label WHERE {
  13.         ?Astronaut rdf:type dbo:Astronaut.
  14.         ?Astronaut rdfs:label ?Astronaut_Label
  15.         FILTER((LANGMATCHES(LANG(?Astronaut_Label), "en")) && (LANGMATCHES(LANG(?Astronaut_Label), "en")))
  16.     }
  17. }
  18.  
  19. 3 - Retorne o nome de indivíduos do tema que tenham alguma característica específica (Nascido nos Estados Unidos)
  20. PREFIX dbo: <http://dbpedia.org/ontology/>
  21. PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  22. SELECT DISTINCT ?Astronaut ?Astronaut_Label ?Country ?Country_Label
  23. WHERE {
  24.     ?Astronaut a dbo:Astronaut.
  25.     ?Astronaut rdfs:label ?Astronaut_Label.
  26.     ?Astronaut dbo:birthPlace ?Country.
  27.     ?Country a dbo:Country.
  28.     ?Country rdfs:label ?Country_Label.
  29.     FILTER((LANGMATCHES(LANG(?Astronaut_Label), "en")) && (LANGMATCHES(LANG(?Astronaut_Label), "en")))
  30.     FILTER((LANGMATCHES(LANG(?Country_Label), "en")) && (LANGMATCHES(LANG(?Country_Label), "en")) && ((STR(?Country_Label)) = "United States"))
  31. }
  32. 4 - Retorne o nome de indivíduos do tema que tenham duas caraterísticas específicas ao mesmo tempo (Nascido nos Estados Unidos && Estado Oklahoma)
  33. PREFIX dbo: <http://dbpedia.org/ontology/>
  34. PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  35. SELECT DISTINCT
  36. ?astronaut ?astronaut_Label ?country ?country_Label ?city ?city_Label
  37. WHERE{
  38.     ?astronaut a dbo:Astronaut.
  39.     ?astronaut rdfs:label ?astronaut_Label.
  40.     ?astronaut dbo:birthPlace ?country.
  41.     ?astronaut dbo:birthPlace ?city.
  42.     ?country a dbo:Country.
  43.     ?country rdfs:label ?country_Label.
  44.     ?city a dbo:City.
  45.     ?city rdfs:label ?city_Label.
  46.     FILTER((LANGMATCHES(LANG(?astronaut_Label), "en")) && (LANGMATCHES(LANG(?astronaut_Label), "en")))
  47.     FILTER((LANGMATCHES(LANG(?country_Label), "en")) && (LANGMATCHES(LANG(?country_Label), "en")) && ((STR(?country_Label)) = "United States"))
  48.     FILTER((LANGMATCHES(LANG(?city_Label), "en")) && (LANGMATCHES(LANG(?city_Label), "en")) && (REGEX(?city_Label, "Oklahoma", "i")))
  49. }
  50.  
  51. 5 - Retorne o nome de indivíduos do tema que tenha uma característica ououtra característica específica (Nascido na Russia OU Ano Nascimento > 1960)
  52. **NÃO FOI POSSÍVEL FILTRAR A DATA PARA (en) POR ISSO RESULTADOS REPETIDOS**
  53.  
  54. PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
  55. PREFIX dbo: <http://dbpedia.org/ontology/>
  56. PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  57. SELECT DISTINCT ?astronaut_Label ?astronaut_birth_date ?country_Label
  58. WHERE {
  59.     ?astronaut a dbo:Astronaut.
  60.     ?astronaut rdfs:label ?astronaut_Label.
  61.     ?astronaut dbo:birthDate ?astronaut_birth_date.
  62.     ?astronaut dbo:birthPlace ?country.
  63.     ?country a dbo:Country.
  64.     ?country rdfs:label ?country_Label.
  65.     FILTER((LANGMATCHES(LANG(?astronaut_Label), "en")) && (LANGMATCHES(LANG(?astronaut_Label), "en")))
  66.     FILTER(((xsd:dateTime(?astronaut_birth_date)) > "1960-01-01T23:59:59-03:00"^^xsd:dateTime) || (LANGMATCHES(LANG(?country_Label), "en")) && ((STR(?country_Label)) = "Russia"))
  67. }
  68.  
  69. 6 - Retorne o nome de indivíduos do tema que cruze dados com outra entidade (Astronaut/Contry)
  70.  
  71. PREFIX dbo: <http://dbpedia.org/ontology/>
  72. PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  73. SELECT DISTINCT ?astronaut ?astronaut_Label ?country ?country_Label
  74. WHERE {
  75.     ?astronaut a dbo:Astronaut.
  76.     ?astronaut rdfs:label ?astronaut_Label.
  77.     ?astronaut dbo:birthPlace ?country.
  78.     ?country a dbo:Country.
  79.     ?country rdfs:label ?country_Label.
  80.     FILTER((LANGMATCHES(LANG(?astronaut_Label), "en")) && (LANGMATCHES(LANG(?astronaut_Label), "en")))
  81.     FILTER((LANGMATCHES(LANG(?country_Label), "en")) && (LANGMATCHES(LANG(?country_Label), "en")) && ((STR(?country_Label)) = "China"))
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement