我试图从dbpedia中只检索英文值和整数。例如,以下SPARQL查询
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 dbr: <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dbo: <http://dbpedia.org/ontology/>
select distinct ?p ?o where {
dbr:Cristiano_Ronaldo ?p ?o
filter(langMatches(lang(?o),'en'))}
}
它正确返回英文值。然而,由于它是整数,它错过了重要的细节,如出生日期,身高,帽数等等。如何制作一个由关于Cristiano Ronaldo的适当信息组成的RDF结果集?
答案 0 :(得分:2)
PREFIX dbr: <http://dbpedia.org/resource/>
SELECT DISTINCT ?p ?o where {
dbr:Cristiano_Ronaldo ?p ?o
BIND(datatype(?o) as ?dt)
FILTER(IF(isliteral(?o) && !bound(?dt), langMatches(lang(?o),'en'), true))
}