How to query Wikidata using SPARQL for a specific property?
I'm using the Wikidata Query Service to try and get all instances within Wikidata that contain a UMLS CUI (Property P2892).
I've tried doing
SELECT ?item
WHERE
{
?item wd:P2892.
}
But am getting the error Query is malformed: Encountered " "." ". "" at line 3, column 17.
How can I fix this error?
See also questions close to this topic
-
I am trying to query my Ontology which I created on Protege by SPARQL (I am 2 weeks old Python user) and I take an error like this
I took many errors, I just tried to apply the example on rdflib website.Imported all the things that I thought i might need but I am stucked.
***import rdflib from rdflib.namespace import FOAF from rdflib import Graph, URIRef, Literal, BNode from rdflib.namespace import FOAF, NamespaceManager g = rdflib.Graph() g.parse("C:/Users/Gamze/Desktop/ontologyproject.rdf")***
Everything is okay till this point. When I try to query, I take many errors. I am a beginner, probably I am losing a big point. Any help would be appreciated. Thank you in advance.
-
SPARQL avoid cross products of multiple output variables
Suppose that I want to get all the rdfs:subclassOf+ for both dbo:Person, and dbo:Politician in one query.
The following query I have right now outputs the cartesian product of both type1 and type2, which I do not want. Is there a way for me to prevent this? (I want the behavior to be as if I am asking two separate queries).
select ?type1 ?type where { dbo:Politician rdfs:subClassOf+ ?type1. dbo:Person rdfs:subClassOf+ ?type2. }
-
Is there a way to rewrite INSERT, MODIFY or DELETE sparql using ARQ Jena Algebra?
I found some SPARQL query manipulation only for SELECT, ASK, CONSTRUCT https://jena.apache.org/documentation/query/manipulating_sparql_using_arq.html and https://jena.apache.org/documentation/query/algebra.html but could not find anything regarding UPDATE operations
Any examples I can look at?
Thanks.
-
Shortest path with SPARQL and blazegraph
This code gives the descendants of Genghis Kahn up to a certain depth (as a graph which can be changed to a table) :
PREFIX bd: <http://www.bigdata.com/rdf#> PREFIX wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX wikibase: <http://wikiba.se/ontology#> #defaultView:Graph PREFIX gas: <http://www.bigdata.com/rdf/gas#> SELECT DISTINCT ?depth ?item ?itemLabel ?pic #?linkTo WHERE { SERVICE gas:service { gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" ; gas:in wd:Q720 ; gas:traversalDirection "Forward" ; gas:out ?item ; gas:out1 ?depth ; gas:maxIterations 4 ; gas:linkType wdt:P40 . } # OPTIONAL { ?item wdt:P40 ?linkTo } OPTIONAL { ?item wdt:P18 ?pic } SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } } ORDER BY ?depth
Is it possible to modify this code in order to obtain the shortest path between Genghis Khan and a particular descendant (e.g. Baltu, Q7070636), including the persons in between and the kinds of relationship (linkType) between them? Generally: How to obtain the shortest path between two certain nodes and as the result a table with the nodes between these nodes and the kinds of relationship between all these nodes (limited to a certain depth)?
-
Why is there no 1:1 relationship between wikidata and en.wikipedia in terms of infoboxes?
Consider Miss Baker and Toyohiro Akiyama on the English Wikipedia. Both their infoboxes include properties "mission" and "time in space". But inspecting their respective entries on Wikidata, Miss Baker is missing these two properties there, while Toyohiro Akiyama entry seems complete.
Why is that?
-
How to export all data about specific entity and all children elements from wikidata or dbpedia in XML/RDF/OWL -database dump
I want to export all data XML/RDF/OWL (ontology) about resource from wikidata or dbpedia. (with all children elements, statements, nested data -database dump)
I'm looking for tool or api or code, and advice how to do that.
Let's say I want all data, and all statements about series How I met your mother, actors, roles, episodes, everything,also their classes and properties (statements).
Link: https://www.wikidata.org/wiki/Q147235 Entity->Q147235
Can maybe SPARQL be written for that, something like this, but with all nested classes, properties, individuals
SELECT ?himym WHERE { BIND(wd:Q147235 as ?himym) . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } }
So the main goal is retrieving database data in rdf/owl.
To be more specific, what I'm looking for something like this, view-source:http://dbpedia.org/data/Friends.rdf but, also statements-resources-about nested data ex. characters, actors, ... up to 3-4 levels of nesting?