You're not going to get useful answers with code like
"SELECT DISTINCT ?abstract"+ "WHERE"
"_:b0 dbpedia-owl:abstract ?abstract"+ "FILTER langMatches(lang(?abstract), 'en')"
because it turns into
SELECT DISTINCT ?abstractWHERE
_:b0 dbpedia-owl:abstract ?abstractFILTER
and you don't want variables named ?abstractWHERE
or ?abstractFILTER
.
This doesn't make any sense either:
String values = "New York";
"?name { " + values +" @en }"
You'd end up with
?name { New York@en }
I expect that what you wanted was
values ?name { "New York"@en }
I'd suggest you take a look into ParameterizedSparqlStrings, and be sure to put terminating newlines, or at least whitespace, in your code. If you had just printed out the query, you could drop it into sparql.org's query validator and you'd have seen the problem right away.
You can write the query like this:
select distinct ?abstract where {
values ?name { "New York"@en }
[ rdfs:label ?name ;
dbpedia-owl:abstract ?abstract ]
filter langMatches(lang(?abstract),'en')
}
SPARQL Results
If you only have the one value for the ?name
and you're not selecting that variable, you can just write it in the query:
select distinct ?abstract where {
[ rdfs:label "New York"@en ;
dbpedia-owl:abstract ?abstract ]
filter langMatches(lang(?abstract),'en')
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…