问题
My query in a multilingual thesaurus looks like this:
select (COUNT(?label) as ?pCount)
where {?term <http://www.w3.org/2004/02/skos/core#prefLabel> ?label
FILTER(langMatches(lang(?label), "DE"))}
I get a huge number of concepts with their German translation, which is what I expect from this query.
I'm now looking for a query giving me all concepts without any German translation, that is all which have no "prefLabel" with "@de".
How would such a query look like?
回答1:
You want either FILTER NOT EXISTS or MINUS:
select ?term
where {
?term a <http://www.w3.org/2004/02/skos/core#Concept>
MINUS {
?term <http://www.w3.org/2004/02/skos/core#prefLabel> ?label
FILTER(langMatches(lang(?label), "DE"))
}
}
Either will work here (I've used MINUS
because it's shorter).
With MINUS
the matching rows of the right hand (or, rather, bottom) block are removed from the other side. In this case terms with german labels are removed from the list of all concepts (?term a <http://www.w3.org/2004/02/skos/core#Concept>
).
(If your concepts aren't explicitly typed as such you could use ?term <http://www.w3.org/2004/02/skos/core#prefLabel> ?someLabel
instead, but you might want to add a DISTINCT
to tidy up)
来源:https://stackoverflow.com/questions/16415515/search-in-a-multilingual-database-for-terms-that-have-not-been-translated-into-a