Sparql Select all different languages appear on Warehouse - sparql

I am trying to select all different language tags that appear on a sparql endpoint (like DBpedia) and display them as a list, but with no luck until now.
A simple Example of Triples on Endpoint.
<person1> rdfs:label "name1"#en
<person1> rdfs:label "name2"#fr
<person2> rdfs:comment "comment"#en
<person2> rdfs:label "name3"#el
The goal is to create a sparql query that returns:
fr
en
el
Is there any way to select languages tags efficiently?
Is there a solution for any sparql version(1.0,1.1) ?

Given your tags include SPARQL, you could try this:
SELECT DISTINCT ?lang
WHERE {
?s ?p ?o .
BIND (lang(?o) AS ?lang)
}

Related

SPARQL - retrieve all preferred terms and their alternate forms in just one language

Beginner warning :) I am exploring the Eurovoc European multilingual database of concept keywords.
SPARQL endpoint can be accessed at http://publications.europa.eu/webapi/rdf/sparql
I wish to find all terms in it only for the Italian language and for each term I want to see the prefLabel but also if there are any alternate forms of that concept (altLabel).
My current query is:
select ?s ?plabel ?alabel where {
?s a skos:Concept .
?s skos:prefLabel ?plabel .
?s skos:altLabel ?alabel .
FILTER (langMatches(lang(?plabel),"it"))
} limit 100
and it properly returns the prefLabel concepts but the altLabels are not related to them. What's wrong? Thanks a lot.

SPARQL - Query all things

I would like to find all DBpedia resources with rdf:type equal to owl:Thing. How can I extract such a list using SPARQL? What query would I need?
Since a triple would be something like
:a rdf:type owl:Thing and SPARQL is using triple patterns to match triples, you need a variable at the positions of the triple which is not fixed:
SELECT * WHERE {
?s a <http://www.w3.org/2002/07/owl#Thing>
}

Retrieving the wider dbpedia vocabulary for tagging pictures

I'm trying to develop a tool in JS for tagging pictures, so I need a set of possible "things" from dbpedia. I already tryed to retrieve this way:
select ?s ?l {
?s a owl:Class .
?s rdf:type ?l
FILTER regex(str(?s), "House", "i").
}
http://dbpedia.org/snorql/?query=select+%3Fs+%3Fl+%7B%0D%0A+++%3Fs+a+owl%3AClass+.%0D%0A+++%3Fs+rdf%3Atype+%3Fl%0D%0A+++FILTER+regex%28str%28%3Fs%29%2C+%22House%22%2C+%22i%22%29.%0D%0A%7D
And also this way:
select ?label
WHERE {
?concept a skos:Concept.
?concept skos:prefLabel ?label.
FILTER regex(str(?label), "^House", "i").
}
http://dbpedia.org/snorql/?query=select+%3Flabel+%0D%0AWHERE+%7B%0D%0A++%3Fconcept+a+skos%3AConcept.%0D%0A++%3Fconcept+skos%3AprefLabel+%3Flabel.%0D%0A++FILTER+regex%28str%28%3Flabel%29%2C+%22%5EHouse%22%2C+%22i%22%29.%0D%0A%7D
In the first case, I just have "instances" of the house "thing", but not the "House" class itself. In the second one, I never retrieve the "house" and the similar thing is "houses". Any alternative for retrieving a better vocabulary based in dbpedia dataset?
If you don't bother to restrict yourself to owl:Thing or to skos:Concept, you can just get things that have a label that contains "house". Rather than using regex, I chose to use contains and lcase, since a string containment could be less expensive than invoking a full regular expression processor.
select ?thing ?label where {
?thing rdfs:label ?label .
filter contains(lcase(?label), "house")
}
SPARQL results (limited to 200)

dbpedia SPARQL query for finding artist properties

I'm trying to get details about an artist via DBPedia and the SPARQL query language, however, it seems almost impossible (with my understanding) of how to get certain pieces of information.
I'm trying to get an Artist and pull information such as their Hometown. I'm guessing the query should be something similar to that of:
SELECT ?c WHERE {
?b <http://dbpedia.org/property/Artist> <http://dbpedia.org/resource/Arctic_Monkeys>.
?b <http://www.w3.org/2002/07/owl#ObjectProperty> <http://dbpedia.org/ontology/hometown>.
?b rdfs:label ?c.
}
If anyone could enlighten me to how it should be done, that would be amazing.
I've been trying out the queries at:
http://dbpedia.org/sparql
If you want to find the label of their hometown, try this:
SELECT ?hometownLabel WHERE {
<http://dbpedia.org/resource/Arctic_Monkeys> <http://dbpedia.org/ontology/hometown> ?hometown .
?hometown <http://www.w3.org/2000/01/rdf-schema#label> ?hometownLabel .
}
Maybe you don't have a good understanding of SPARQL syntax. Unlike SQL, SPARQL search results by writing some triples with unknow variables in the WHERE clause.
you can try:
prefix dbpedia-owl:<http://dbpedia.org/ontology/>
SELECT ?c
WHERE {
<http://dbpedia.org/resource/Arctic_Monkeys> dbpedia-owl:hometown ?c.
}
With this search, you will get Arctic_Monkeys' hometown.
SELECT ?hometown
WHERE {
dbr:Arctic_Monkeys dbo:hometown ?label.
?label rdfs:label ?hometown.
FILTER(langMatches(lang(?hometown), "en"))
}

multilingual sparql

I want to query a triple store which is multilingual.
Query that works:
SELECT * WHERE {?s ?p "sdfsdf"#en}
I want "sdfsdf" to be an attribute in general like ?o#en.
How should i query then?
Filter by the language of the object:
select * where { ?s ?p ?o . filter (lang(?o) = "en") }
Note that your results will be of the form "sdfsdf"#en, rather than just the lexical form "sdfsdf". (You can do that additional work in SPARQL 1.1, and processors like ARQ using extensions)