SPARQL DBpedia - Retrieve category information in any language by using labels - resources

I have a problem, which I explain on following example:
I want to retrieve all information in any language on a category. I must use ?category as a label and the language labels en, as they are inputs in my program.
The query looks like this, but when I change the language I don't receive any information on the category. I know the problem lies in the dcterms:subject, because ?category returns http://dbpedia.org/resource/Category:Countries_in_Europe (see first example below).
For example to search for a category label in german you have to use http://de.dbpedia.org/resource/Kategorie:Staat_in_Europa (see second example below).
prefix dcterms: <http://purl.org/dc/terms/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?objectLabel WHERE {
?subject dcterms:subject ?category ; rdfs:label ?objectLabel
?category rdfs:label "Countries in Europe"#en .
FILTER (LANG(?objectLabel)='en')
}
Equivalent query in different language that doesn't work as example:
prefix dcterms: <http://purl.org/dc/terms/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?objectLabel WHERE {
?subject dcterms:subject ?category ; rdfs:label ?objectLabel
?category rdfs:label "Staat in Europa"#de .
FILTER (LANG(?objectLabel)='de')
}
Is there a similar or different way / method to solve the problem? Thanks in advance for any help.

Related

is there a method to select all categories MeSH with sparql

i want to get data with sparql from Medical Subject Headings RDF
i try to do this code :
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX meshv: <http://id.nlm.nih.gov/mesh/vocab#>
PREFIX mesh: <http://id.nlm.nih.gov/mesh/>
PREFIX mesh2015: <http://id.nlm.nih.gov/mesh/2015/>
PREFIX mesh2016: <http://id.nlm.nih.gov/mesh/2016/>
PREFIX mesh2017: <http://id.nlm.nih.gov/mesh/2017/>
SELECT DISTINCT ?descriptor ?label
FROM <http://id.nlm.nih.gov/mesh>
WHERE {
mesh:D009369 meshv:treeNumber ?treeNum .
?childTreeNum meshv:parentTreeNumber+ ?treeNum .
?descriptor meshv:treeNumber ?childTreeNum .
?descriptor rdfs:label ?label .
}
ORDER BY ?label
this code return
descriptor label
mesh:D000182 ACTH Syndrome, Ectopic
mesh:D049913 ACTH-Secreting Pituitary Adenoma
mesh:D000008 Abdominal Neoplasms
but me i want to get from this page for example https://meshb.nlm.nih.gov/record/ui?ui=D000172 :
Musculoskeletal Diseases [C05]
Bone Diseases [C05.116]
Bone Diseases, Endocrine [C05.116.132]
Acromegaly [C05.116.132.082]
Congenital Hypothyroidism [C05.116.132.256]
.........
but i want to collect all data (code with label) from mesh, not only this example
I know I'm not answering your question, but you are missing the rdfs prefix in the beginning...
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
Paul

How to find the Polygons Intersection inside Apache Fuseki Server?

I am using Apache Jena Fuseki Server for Storing Geo Coordinates of location. How to find out that if two polygons or two rectangles intersect each other inside Fuseki. Please share links related to it if possible. Thank you.
Hello...I am just updating question based on the below comments. Please suggest me regarding the problem I am facing. I have stored geocoordinates in WKT serialization format. When I execute below query
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://example.org/#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX spatial: <http://jena.apache.org/spatial#>
SELECT ?object
WHERE {
GRAPH <http://project/base/default> {
?subject geo:asWKT ?object .
} }
I get these below results.
object
1
"POLYGON((8.463699817657472 48.99872928913063,8.463887572288515 48.998644821906865,8.46399486064911 48.998764483764916,8.46425771713257 48.99865538031766,8.464375734329225 48.998746886450874,8.463919758796694 48.99893693711346,8.463699817657472 48.99872928913063))"
2
"POLYGON((8.463560342788698 48.99847940651206,8.463560342788698 48.99864834137738,8.46377491950989 48.99864834137738,8.46377491950989 48.99847940651206,8.463560342788698 48.99847940651206))"
3
"POLYGON((8.463447690010073 48.99835974396915,8.463447690010073 48.99849348443939,8.463646173477175 48.99849348443939,8.463646173477175 48.99835974396915,8.463447690010073 48.99835974396915))"
4
"POLYGON((8.463254570961 48.99821544463795,8.463254570961 48.99838438039854,8.463635444641115 48.99838438039854,8.463635444641115 48.99821544463795,8.463254570961 48.99821544463795))"
5
"POLYGON((8.463689088821413 48.99826823712468,8.463689088821413 48.99845477012966,8.46402168273926 48.99845477012966,8.46402168273926 48.99826823712468,8.463689088821413 48.99826823712468))"
6
"POLYGON((8.463892936706545 48.99843013373508,8.463892936706545 48.998588510344774,8.464316725730898 48.998588510344774,8.464316725730898 48.99843013373508,8.463892936706545 48.99843013373508))"
7
"POLYGON((8.463093638420107 48.99805354732974,8.463093638420107 48.998243600637835,8.463737368583681 48.998243600637835,8.463737368583681 48.99805354732974,8.463093638420107 48.99805354732974))"
8
"POLYGON((8.463619351387026 48.99797963751407,8.463619351387026 48.998180249615714,8.464118242263796 48.998180249615714,8.464118242263796 48.99797963751407,8.463619351387026 48.99797963751407))"
9
"POLYGON((8.464407920837404 48.998303432084754,8.464407920837404 48.99857443244431,8.46477270126343 48.99857443244431,8.46477270126343 48.998303432084754,8.464407920837404 48.998303432084754))"
10
"POLYGON((8.464225530624391 48.99806762537742,8.464225530624391 48.99839141937611,8.464820981025698 48.99839141937611,8.464820981025698 48.99806762537742,8.464225530624391 48.99806762537742))"
Then later I want to filter out these geo:WKT objects based on geo:intersection (Intersection or equals or contains methods). And I updated my query as below.
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://example.org/#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX spatial: <http://jena.apache.org/spatial#>
SELECT ?object
WHERE {
GRAPH <http://project/base/default> {
?subject geo:asWKT ?object .
?object geo:equals "POLYGON((8.463699817657472 48.99872928913063,8.463887572288515 48.998644821906865,8.46399486064911 48.998764483764916,8.46425771713257 48.99865538031766,8.464375734329225 48.998746886450874,8.463919758796694 48.99893693711346,8.463699817657472 48.99872928913063))"
} }
Which should result me atleast the coordinates of first geo object which really equals the POLYGON coordinates but I get empty results as shown in below image. Please suggest me where I am getting it wrong.

sparql query - triple

I am a biology trying to understand the meaning of a triple from this SPARQL query. If "a" is a triple, what are the resources for subject, object and predicate in this sample query?
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX sio: <http://semanticscience.org/resource/>
PREFIX efo: <http://www.ebi.ac.uk/efo/>
PREFIX atlas: <http://rdf.ebi.ac.uk/resource/atlas/>
PREFIX atlasterms: <http://rdf.ebi.ac.uk/terms/atlas/>
SELECT DISTINCT ?experiment ?description WHERE
{?experiment
a atlasterms:Experiment ;
dcterms:description ?description ;
atlasterms:hasAssay
[atlasterms:hasSample
[atlasterms:hasSampleCharacteristic
[ atlasterms:propertyType ?propertyType ;
atlasterms:propertyValue ?propertyValue]
]
]
filter regex (?description, "diabetes", "i")
}
I appreciate your help?
Thanks,
AD
?experiment
a atlasterms:Experiment ;
is the same as
?experiment a atlasterms:Experiment ;
is the same as
?experiment rdf:type atlasterms:Experiment ;
so the form in the query is just a whitespace rearrangement and using the built-in abbreviation "a" for property rdf:type.
See http://www.sparql.org/query-validator.html for an online formatter of SPARQL queries.
A simpler query is:
SELECT DISTINCT ?experiment ?description
WHERE
{ ?experiment rdf:type atlasterms:Experiment .
?experiment dcterms:description ?description
FILTER regex(?description, "diabetes", "i")
}
because
SELECT DISTINCT ?experiment ?description
means that the ?propertyType/?propertyValue part is not affecting the outcome.

get dbpedia type/category for any word

I am trying to get type/category to which the word belongs to like if its basketball then its under the category sports and if its tea then beverage is the category.
I tried :
select * where {basketball} LIMIT 100
and
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbpprop: <http://dbpedia.org/property/>
PREFIX dbres: <http://dbpedia.org/resource/>
select ? {
a owl:basketball .
}
limit 10
also
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbpprop: <http://dbpedia.org/property/>
PREFIX dbres: <http://dbpedia.org/resource/>
SELECT ?y WHERE {
?y dbpedia-owl:binomialAuthority dbres:basketball.
}
limit 10
but there is a query error especially if I dont know the property of the word typed.How can I get the name of the category.
May be you can query rdf:type of basketball.
PREFIX dbres: <http://dbpedia.org/resource/>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
select ?o where {dbres:Basketball rdf:type ?o} LIMIT 10
Demo

SPARQL how to deal with different cased queries?

I am still a bit new to SPARQL. I have set up a dbpedia endpoint for our company. I have no idea what the end user will be querying and, since DBpedia is case sensitive I pass both title case & uppercase versions for subjects vs something like a person; e.g. "Computer_programming" vs "Alcia_Keys". Rather than pass in 2 separate queries what is the most effecient way to achieve this? I've tried the IN operator (from this question) but I seem to be failing somewhere.
select ?label ?abstract where {
IN (<http://dbpedia.org/resource/alicia_keys>, <http://dbpedia.org/resource/Alicia_Keys>) rdfs:label ?label;
dbpedia-owl:abstract ?abstract.
}
LIMIT 1"""
since DBpedia is case sensitive I pass both title case & uppercase
versions for subjects vs something like a person; e.g.
"Computer_programming" vs "Alcia_Keys". Rather than pass in 2 separate
queries what is the most effecient way to achieve this?
URIs should be viewed as opaque. While DBpedia generally has some nice structure so that you can lucky by concatenating http://dbpedia.org/resource and some string with _ replacing , that's really not a very robust way to do something. A better idea is to note that the string you're getting is probably the same as a label of some resource, modulo variations in case. Given that, the best idea would be to look for something with the same label, modulo case. E.g.,
select ?resource where {
values ?input { "AliCIA KeYS" }
?resource rdfs:label ?label .
filter ( ucase(str(?label)) = ucase(?input) )
}
That's actually going to be pretty slow, though, because you'll have to find every resource, do some string processing on its label. It's an OK approach, in principle though.
What can be done to make it better? Well, if you know what kind of thing you're looking for, that will help a lot. E.g., you could restrict the query to Persons:
select distinct ?resource where {
values ?input { "AliCIA KeYS" }
?resource rdf:type dbpedia-owl:Person ;
rdfs:label ?label .
filter ( ucase(str(?label)) = ucase(?input) )
}
That's an improvement, but it's still not all that fast. It still, at least conceptually, has to touch each Person and examine their name. Some SPARQL endpoints support text indexing, and that's probably what you need if you want to do this efficiently.
The best option, of course, would be to simply ask your users for a little bit more information, and to normalize the data in advance. If your user provides "AliCIA KEyS", then you can do the normalization to "Alicia Keys"#en, and then do something ilke:
select distinct ?resource where {
values ?input { "Alicia Keys"#en }
?resource rdfs:label ?input .
}

Resources