【发布时间】:2026-02-01 23:15:03
【问题描述】:
我正在按资源标签查询 SPARQL (http://dbpedia.org/sparql) 中的 DBpedia 类型
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX : <http://dbpedia.org/resource/>
PREFIX ru: <http://ru.dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?type ?superType WHERE { {
?res rdfs:label "HarryPotter"@en.
} UNION {
?redir dbo:wikiPageRedirects ?res .
?redir rdfs:label "HarryPotter"@en .
}
?res rdf:type ?type .
OPTIONAL {
?type rdfs:subClassOf ?superType .
}
}
但是如果我知道确切的资源 - http://dbpedia.org/page/Harry_Potter 怎么办?我试过类似的东西:
?res a :Harry_Potter.
但它不起作用。
如果我知道资源 URI,如何查询 DBpedia 类型和超类型?我不知道应该使用哪个属性或运算符(例如,rdfs:Resource、a 等,它们不起作用)
【问题讨论】: