sparql

SPARQL: Get all the entities of subclasses of a certain class

只愿长相守 提交于 2019-12-22 04:00:13
问题 I've to get all the instances of a class C and subclasses (direct or indirect) of C, in SPARQL. I can get all the direct subclasses of C in this way: SELECT ?entity WHERE { ?subclass rdfs:subClassOf :C . ?entity rdf:type ?subclass . } But I can't get the instances of an indirect subclass and neither any instance of C. As I know (I've pre-calculated them) all the subclasses (direct and indirect of C), and I can build a dynamic query, is it possible build a query like the following one? SELECT

Logarithm Function in SPARQL Query

Deadly 提交于 2019-12-21 20:07:28
问题 I am trying to create a SPARQL query that performs the logarithm function on the returned results. I have implemented the Jena SPARQL engine in my java program, but have only been able to find these available functions : http://jena.sourceforge.net/ARQ/library-function.html Does anybody know of a way to take the logarithm (preferably the natural log) of a SPARQL return variable? Example query that works: SELECT DISTINCT ((?Transactions_Num) AS ?BusinessValue) WHERE {{?BusinessProcess relation

Sparql query with Blank node can be complex

情到浓时终转凉″ 提交于 2019-12-21 12:41:21
问题 I read this blog article, Problems of the RDF model: Blank Nodes, and there's mentioned that using blank nodes can complicate the handling of data. Can you give me an example why using blank nodes is difficult to perform a SPARQL query? I do not understand the complexity of blank nodes. Can you explain me the meaning and semantics of an existential variable? I do not understand clearly this explanation given in the RDF Semantics Recommendation, 1.5. Blank Nodes as Existential Variables. 回答1:

How to match exact string literals in SPARQL?

不问归期 提交于 2019-12-21 12:27:30
问题 I have this query. It matches anything which has "South" in its name. But I only want the one whose foaf:name is exactly "South". SELECT Distinct ?TypeLabel WHERE { ?a foaf:name "South" . ?a rdf:type ?Type . ?Type rdfs:label ?TypeLabel . } 回答1: (Breaking out of comments for this) Data issues The issue is the data, not your query. If use the following query: SELECT DISTINCT ?a WHERE { ?a foaf:name "Imran Khan" . } You find (as you say) "Imran Khan Niazy". But looking at the dbpedia entry for

Using the 'GRAPH' keyword in SPARQL to fetch remote graphs

有些话、适合烂在心里 提交于 2019-12-21 10:17:00
问题 I'm looking to use SPARQL for a relatively basic task: Given a FOAF graph, I'd like to parse the elements I find in there, get their tags (if they exist) and then, use those as new graphs from which to find information about those people. So for instance, you could imagine a simple use case where I want to run a SPARQL query to list all of my favorite foods (as per my FOAF file), and also the favorite foods of all my friends. Here is what this looks like at the moment. Note that for testing

How to rank values in SPARQL?

和自甴很熟 提交于 2019-12-21 05:33:14
问题 I would like to create a ranking of observations using SPARQL. Suppose I have: @prefix : <http://example.org#> . :A :value 60 . :B :value 23 . :C :value 89 . :D :value 34 . The ranking should be: :C = 1 (the highest), :A = 2, :D = 3, :B = 4. Up until now, I was able solve it using the following query: prefix : <http://example.org#> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?x ?v ?ranking { ?x :value ?v . { SELECT (GROUP_CONCAT(?x;separator="") as ?ordered) { { SELECT ?x

Sparql: Arithmetic operators between variables?

北城以北 提交于 2019-12-21 04:13:08
问题 Hi I have a query like this: SELECT ?a ?b WHERE { ?c property:name "myThing"@en ?c property:firstValue ?b ?c property:secondValue ?a } How can I divide the first nuber and the second? idealy somthing like this: SELECT ?a/?b WHERE { ?c property:name "myThing"@en ?c property:firstValue ?b ?c property:secondValue ?a } Thank you 回答1: In SPARQL 1.1 you can do it using Project expressions like so: PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT (xsd:float(?a)/xsd:float(?b) AS ?result) WHERE

Excluding Blank Nodes from SPARQL query results

安稳与你 提交于 2019-12-21 02:35:13
问题 I am using RDFLib to query on the Semantic Dicom Ontology. I am querying for owl:Class in the graph constructed from the above ontology. RDFLib returns results which contain blank nodes and I wish to exclude such queries. My query - from rdflib import Graph g = Graph() g.parse('dicom.owl') q = """SELECT ?c WHERE {?c rdf:type owl:Class}""" qres = g.query(q) dicom.owl is the Semantic Dicom Ontology downloaded in my machine. Some of the results that I receive - How can I modify my query to

SPARQL query against DBPedia to get all property-value of the item

允我心安 提交于 2019-12-20 07:25:54
问题 I am a novice in Semantic Web and I would like to retrieve all property-value pairs of "apple" from DBPedia using SPARQL query. Below I have written the query in http://dbpedia.org/sparql editor, but it returns no any results.Could you tell me where I make a mistake, please? PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix dbo: <http://dbpedia.org/ontology/> prefix owl: <http://www.w3.org/2002/07/owl#> prefix prov: <http:/

How to generate all triples that fit a particular node type or/and edge type using SPARQL query?

偶尔善良 提交于 2019-12-20 07:23:10
问题 It is a follow up question to : How to list and count the different types of node and edge entities in the graph data using SPARQL query? So assuming I have the different node entities and edge entities of a given graph, how do I go about listing all triples, given a node-edge-node pattern? And how do I generate ALL node-edge-node patterns given the node and edge entities? Example: If there is a network consisting of papers(nodes), authors(nodes), conferences(nodes), iswrittenby(edge),