如何使用Sparql Query在dbpedia中选择具有特定属性的资源?

时间:2017-06-22 15:54:24

标签: sparql rdf semantic-web dbpedia apache-jena

我有查询 -

PREFIX rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dbo:    <http://dbpedia.org/ontology/>
PREFIX rdfs:   <http://www.w3.org/2000/01/rdf-schema#>

#select count(DISTINCT ?instance)  # The number of suitable instances
#select DISTINCT ?instance ?type  # Full Ground-truth dataset
select DISTINCT ?instance ?domain ?range ?subClassOf  # Full Algorithm input dataset (sampling might be required)
where {
   ?instance rdf:type ?type;
             rdfs:domain ?domain;
             rdfs:range ?range;
             rdfs:subClassOf* ?subClassOf.
}
ORDER BY ?instance

- 返回具有typedomainrange属性的所有三元组。结果集就像 -

<http://dbpedia.org/ontology/torqueOutput>  <http://www.w3.org/2000/01/rdf-schema#domain>  <http://dbpedia.org/ontology/AutomobileEngine>  .
<http://dbpedia.org/ontology/torqueOutput>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://www.w3.org/2002/07/owl#FunctionalProperty>  .
<http://dbpedia.org/ontology/torqueOutput>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property>  .
<http://dbpedia.org/ontology/torqueOutput>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://www.w3.org/2002/07/owl#DatatypeProperty>  .
<http://dbpedia.org/ontology/torqueOutput>  <http://www.w3.org/2000/01/rdf-schema#range>  <http://www.w3.org/2001/XMLSchema#double>  .
<http://dbpedia.org/ontology/torqueOutput>  <http://www.w3.org/ns/prov#wasDerivedFrom>  <http://mappings.dbpedia.org/index.php/OntologyProperty:torqueOutput>  .
<http://dbpedia.org/ontology/torqueOutput>  <http://www.w3.org/2000/01/rdf-schema#label>  "torque output (Nm)"@en  .
<http://dbpedia.org/ontology/displacement>  <http://www.w3.org/2000/01/rdf-schema#domain>  <http://dbpedia.org/ontology/AutomobileEngine>  .
<http://dbpedia.org/ontology/displacement>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://www.w3.org/2002/07/owl#FunctionalProperty>  .
<http://dbpedia.org/ontology/displacement>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property>  .
<http://dbpedia.org/ontology/displacement>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://www.w3.org/2002/07/owl#DatatypeProperty>  .
<http://dbpedia.org/ontology/displacement>  <http://www.w3.org/2000/01/rdf-schema#range>  <http://www.w3.org/2001/XMLSchema#double>  .
<http://dbpedia.org/ontology/displacement>  <http://www.w3.org/ns/prov#wasDerivedFrom>  <http://mappings.dbpedia.org/index.php/OntologyProperty:displacement>  .
<http://dbpedia.org/ontology/displacement>  <http://www.w3.org/2000/01/rdf-schema#label>  "cilindrada (μ³)"@es  .
<http://dbpedia.org/ontology/displacement>  <http://www.w3.org/2000/01/rdf-schema#label>  "displacement (μ³)"@en  .

如您所见,所有主题均为<http://dbpedia.org/ontology/......,但我希望将<http://dbpedia.org/resource/....作为我的主题。有没有办法让他们?我想要的三元组看起来像这样:

<http://dbpedia.org/resource/Otto_Georg_Thierack>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://xmlns.com/foaf/0.1/Person>  .
<http://dbpedia.org/resource/Otto_Georg_Thierack>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://dbpedia.org/ontology/Person>  .
<http://dbpedia.org/resource/Otto_Georg_Thierack>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://dbpedia.org/ontology/Agent>  .
<http://dbpedia.org/resource/Otto_Georg_Thierack>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://schema.org/Person>  .
<http://dbpedia.org/resource/Otto_Georg_Thierack>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://www.w3.org/2002/07/owl#Thing>  .
<http://dbpedia.org/resource/Erich_Wasicky>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://www.w3.org/2002/07/owl#Thing>  .
<http://dbpedia.org/resource/Erich_Wasicky>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://dbpedia.org/ontology/Person>  .
<http://dbpedia.org/resource/Erich_Wasicky>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://dbpedia.org/ontology/Agent>  .
<http://dbpedia.org/resource/Erich_Wasicky>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://schema.org/Person>  .

0 个答案:

没有答案