sparql

different output from rdflib SPARQL query when using initBindings

余生颓废 提交于 2019-12-11 11:07:09
问题 I've been trying to run a query on rdflib graph (loaded with schema.rdfa from schema.org ) to find the ancestors. E.g. As per Schema for Corporation the ancestors are Thing > Organization > Corporation This code works perfectly, giving me the output I desire, except that it does not use initBindings and I have to format the query string. import rdflib subject = rdflib.term.URIRef('http://schema.org/Corporation') inplace_query = ''' SELECT ?class where { <%(subject_uri)s> rdfs:subClassOf* ?mid

How to query DBPedia data for a given Wikipedia URL?

纵然是瞬间 提交于 2019-12-11 10:55:58
问题 If I want to query the RDF for Appomattox Court House National Historical Park in DBPedia, what's the query string if I search by wiki page URL? I tested the following string but get no result: select ?building where { ?building a dbo:Building . ?building foaf:primaryTopic <http://en.wikipedia.org/wiki/Appomattox_Court_House_National_Historical_Park> } LIMIT 100 回答1: As said in my comment as well: the problem is that you are using the foaf:primaryTopic relation the wrong way around. The wiki

SPARQL - how to get individual data property from linked individual

早过忘川 提交于 2019-12-11 10:53:32
问题 I build this ontology in protege. I have this individual ev001 that has these types Room , hasRoom only {rm001} and rm001 has data property roomName "room 1"^^xsd:string . Right now I have a SPARQL query that returns Event Room RoomName ev001 {rm001} My question is, how to get the room name from there, here is my query so far SELECT ?event ?room ?roomname WHERE { ?x owl:onProperty base:hasRoom . ?event a base:FilmScreening ; a ?x . ?x owl:allValuesFrom ?room . } Any advice is appreciated,

owl:TransitiveProperty in query

对着背影说爱祢 提交于 2019-12-11 10:33:42
问题 I have done a family tree. I also defined transitive property: childOf. Now I want to make SPARQL Query which give me all descendants of one of members of family. How can I do it? Thanks 回答1: If your triple store supports OWL reasoning and you've defined your childOf property to be transitive (shouldn't it be called descendantOf by the way!), then it should infer childOf properties directly between all related nodes. So, it should be enough to query it like this (prefixes omitted for brevity)

SPARQL Federated Query Not Returning All Solutions

不打扰是莪最后的温柔 提交于 2019-12-11 10:30:31
问题 This is an evolution of this question. Basically I am having trouble getting all the solutions to a SPARQL query from a remote endpoint. I have read through section 2.4 here because it seems to describe a situation almost identical to mine. The idea is that I want to filter my results from DBPedia based on information in my local RDF graph. The query is here: PREFIX ns1: <http://www.semanticweb.org/caeleanb/ontologies/twittermap#> PREFIX dbo: <http://dbpedia.org/ontology/> SELECT * WHERE { ?p

Retrieving common Classes' attributes from DBPedia with SPARQL

橙三吉。 提交于 2019-12-11 09:58:12
问题 I'm trying to retrieve some properties for certain classes in dbpedia. Consider you have a country. It does exist in the ontology but I want to retrieve some related common properties, like name, currency, time zone, etc. But there is no such information in http://dbpedia.org/ontology/Country. SELECT * WHERE { <http://dbpedia.org/ontology/Country> ?predicate ?object. } And it is logic. The query just return 15 matchings, and even wikipedia does not have such information (see https://en

Extract Chemical Data from DBpedia via SPARQL

浪子不回头ぞ 提交于 2019-12-11 09:47:39
问题 I'd like to know how to submit a SPARQL query to DDBpedia and be given back a table that includes the information found in the Wikipedia "chembox" info box template, such as molecular weight or formula. So, the first step was just to make a query whose results should be a list of chemical substances that had the formula and molecularWeight properties included. But the following returns no results: SELECT * WHERE { ?y rdf:type dbpedia-owl:ChemicalSubstance. ?y rdfs:label ?Name . ?y dbpedia

SPARQLWrapper HTTP Error 401: Unauthorized

旧巷老猫 提交于 2019-12-11 09:44:14
问题 I secured my SPARQL endpoint via SQL Accounts according to VirtSPARQLProtectSQLDigestAuthentication. Before this operation, I can get the data through the code: from SPARQLWrapper import SPARQLWrapper, JSON, DIGEST sparql = SPARQLWrapper("http://example.org/sparql") sparql.setQuery("...") sparql.setReturnFormat(JSON) results = sparql.query().convert() And after that, I use the DIGEST way to get the data, from SPARQLWrapper import SPARQLWrapper, JSON, DIGEST sparql = SPARQLWrapper("http:/

SPARQL - learning by example

十年热恋 提交于 2019-12-11 09:42:45
问题 In short, if someone instructs me, "Get a list of databases which include Oracle, Mysql, DB2, MSSQL, etc.," how can I actually establish which fields and information I need to create the query? I downloaded DBpedia and grepped the triples, e.g., $ `grep 'Oracle' * | grep 'Database' article_categories_en.nt:<http://dbpedia.org/resource/Oracle_Database> <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Relational_database_management_systems> .` How do I create a SPARQL

error: cannot find symbol resultset

醉酒当歌 提交于 2019-12-11 09:36:33
问题 I am really stuck at this...I am trying to convert Result Set into string and this is my code : QueryExecution qExec = QueryExecutionFactory.create(s, ds) ; ResultSet rs = qExec.execSelect() ; //String x=rs.toString(); String[] arr = null; while (rs.next()) { String em = (String)rs.getString(0); arr = em.split("\n"); for (int i =0; i < arr.length; i++){ subjectoutput.setText(arr[i]); } } and it gives error: JavaApplication2.java:137: error: incompatible types while (rs.next()) { ^ required: