sparql

Comparing two strings with SPARQL

空扰寡人 提交于 2019-12-24 06:43:57
问题 i'm using the regex function with SPARQL. Is there a function which find a string that have minimum distance from another one? I mean, i need a function which gives me the most similar word compared with another one. Actually i pass two variables (these variables take values form two different datasets) and compare just considering these case insensitive. So i need a function that can compare two variables. Does anybosy know anything ? 回答1: There is no such function in standard SPARQL.

constructing graph using rdflib for the outputs from sparql 'SELECT' query with sparqlWrapper

廉价感情. 提交于 2019-12-24 05:59:46
问题 I am trying to construct a graph out of the results from SPARQL query. For the purpose of the query construction, I'm using SparqlWrapper and DBpedia as the knowledge base. from SPARQLWrapper import SPARQLWrapper, JSON from rdflib import Namespace, Graph, URIRef from rdflib.namespace import RDF, FOAF g = Graph() name = "Asturias" #labelName = URIRef("<http://dbpedia.org/resource/" + name +">") sparql = SPARQLWrapper("http://dbpedia.org/sparql") sparql.setQuery(""" PREFIX rdfs: <http://www.w3

constructing graph using rdflib for the outputs from sparql 'SELECT' query with sparqlWrapper

↘锁芯ラ 提交于 2019-12-24 05:59:21
问题 I am trying to construct a graph out of the results from SPARQL query. For the purpose of the query construction, I'm using SparqlWrapper and DBpedia as the knowledge base. from SPARQLWrapper import SPARQLWrapper, JSON from rdflib import Namespace, Graph, URIRef from rdflib.namespace import RDF, FOAF g = Graph() name = "Asturias" #labelName = URIRef("<http://dbpedia.org/resource/" + name +">") sparql = SPARQLWrapper("http://dbpedia.org/sparql") sparql.setQuery(""" PREFIX rdfs: <http://www.w3

Adding an OPTIONAL clause to a SPARQL query using Jena ARQ

老子叫甜甜 提交于 2019-12-24 05:41:14
问题 Is it possible to programmatically add an OPTIONAL clause to a SPARQL query using the Jena ARQ API? I would like to programmatically take this query: select ?concept ?p ?o where {?s ?p ?o . } limit 10 To this: SELECT ?concept ?p ?o ?test WHERE { ?s ?p ?o OPTIONAL { ?concept <http://www.test.com/test> ?test } } LIMIT 10 Through ARQ it's simple to add the additional result variable ?test : Query q = QueryFactory.create(query) query.addResultVar(var); But from what I've found in the API docs and

SPARQL query does not yield expected results

北城余情 提交于 2019-12-24 04:07:36
问题 I'm using this SPARQL query to obtain a list of European countries: SELECT ?item $itemLabel WHERE { ?item wdt:P31 wd:Q6256. #?item wdt:P30 wd:Q46 #?item wdt:P361* wd:Q46. ?item wdt:P30|wdt:P361* wd:Q46. SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } ORDER BY ASC($itemLabel) Line 3 limits the results to instances of Q6256, i.e. countries. Line 4 (currently commented out) limits the results to items which are on the continent Q46 (Europe). Line 5 (currently commented out)

Standard regex to prevent SPARQL injection?

房东的猫 提交于 2019-12-24 03:44:14
问题 I am developing a RESTful API in scala that sends SPARQL-queries to a triplestore. I read an article about the threat of SPARQL-injections when user defined params (URL params in a HTTP get request) are directly put in the SPARQL (e.g. in a fulltext search). I saw some Jena specific solutions (using its Java API) that are not useful for me. Is there some kind of standard regex search and replace pattern to escape malicious characters in a string that should be integrated in a SPARQL-query?

Pull string from RDF node

时光毁灭记忆、已成空白 提交于 2019-12-24 03:13:02
问题 Im trying to get the data in a more readable format when using a SPARQL query with Jena, however I have no idea how to extract the data in a proper way. As for now, the output is: "http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SaucelitoCanyon" Where instead would like to just have the "SaucelitoCanyon" as a output. public JenaQuery() { String wineRegion = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n" + "PREFIX xsd:

Sesame : how to remove the inference during queries?

馋奶兔 提交于 2019-12-24 02:51:30
问题 I'm looking for a solution in order to "remove" the inference during a query launched on Sesame. I must use a "Native Java Store RDF Schema" repository and I have this query : I have an instance, a NamedIndividual, and I want the uri of the class whose instance it is : SELECT DISTINCT ?uri WHERE { <http://www.semanticweb.org/ontotest#myInstance> rdf:type ?uri . FILTER (?uri rdf:type owl:Class) } The problem is that I get severals URI (whom the good URI) instead of one because of the inference

How to return a single foaf:name?

人盡茶涼 提交于 2019-12-24 02:32:03
问题 I have the following DBpedia SPARQL that shows philosophers that influenced philosophers. However, it returns duplicates when the philosopher has more than one foaf:name : SELECT ?name ?influencedName WHERE { ?philosopher a dbpedia-owl:Philosopher ; dbpedia-owl:influenced ?influenced ; foaf:name ?name . ?influenced a dbpedia-owl:Philosopher ; foaf:name ?influencedName . } SPARQL results How can I return a single name if there are multiple values for ?name and ?includedName . I would be happy

SPARQL: unable to use FactForge endpoint

情到浓时终转凉″ 提交于 2019-12-24 02:22:58
问题 I am using python to run some sparql queries. I want to extract information from http://factforge.net/sparql sparql = SPARQLWrapper("http://factforge.net/sparql") query = """ # F02: Big Cities in Eastern Europe PREFIX onto: <http://www.ontotext.com/> PREFIX gn: <http://www.geonames.org/ontology#> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX dbr: <http://dbpedia.org/resource/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> SELECT *