sparql

Parameterized SPARQL query with JENA

元气小坏坏 提交于 2019-12-19 17:37:46
问题 I'm trying to build a small semantic web application using Jena framework, JSP and JAVA. I have a remote SPARQL endpoint and I've already written a simple query which works fine but now I need to use some parameters. Here is my code so far: final static String serviceEndpoint = "http://fishdelish.cs.man.ac.uk/sparql/"; String comNameQuery = "PREFIX fd: <http://fishdelish.cs.man.ac.uk/rdf/vocab/resource/> " + "SELECT ?name ?language ?type" + "WHERE { ?nameID fd:comnames_ComName ?name ;" + "fd

Fetching a list of books adapted into films from dbpedia

我只是一个虾纸丫 提交于 2019-12-19 12:01:27
问题 I am trying to fetch a list of American movies adapted from books from dbpedia. This is what I have so far: PREFIX onto: <http://dbpedia.org/ontology/> PREFIX dcterms: <http://purl.org/dc/terms/> SELECT * WHERE { ?movie dcterms:subject <http://dbpedia.org/resource/Category:American_films> . ?movie dcterms:subject <http://dbpedia.org/resource/Category:Films_based_on_novels> . ?movie onto:basedOn ?book . ?book a onto:Book . } I get only 4 results back. Is there another property I can use to get

SPARQL Query “COUNT” in Virtuoso Jena API - QueryParseException

主宰稳场 提交于 2019-12-19 11:57:05
问题 Same query works in DBpedia Endpoint(http://ko.dbpedia.org/sparql), but not in my Java code. I am just trying to extract the frequency using "COUNT" function. VirtGraph set = new VirtGraph("http://ko.dbpedia.org", HOST, USERNAME, PASSWORD); Query freqsparql = QueryFactory.create("SELECT ?class count(distinct ?s) as ?count where{?s <http://ko.dbpedia.org/property/이름> ?o. ?s a ?class.} order by DESC(?count)"); VirtuosoQueryExecution freqvqe = VirtuosoQueryExecutionFactory.create(freqsparql, set

DBpedia SPARQL query returns multiple and duplicate records

孤者浪人 提交于 2019-12-19 11:22:18
问题 I am quite new to SPARQL and also becoming confused by the manifold syntax standards existing for it. I am struggling to fetch unique data from DBpedia using the following query: SELECT DISTINCT ?Museum, ?name, ?abstract, ?thumbnail, ?latitude, ?longitude, ?photoCollection, ?website, ?homepage, ?wikilink WHERE { ?Museum a dbpedia-owl:Museum ; dbpprop:name ?name ; dbpedia-owl:abstract ?abstract ; dbpedia-owl:thumbnail ?thumbnail ; geo:lat ?latitude ; geo:long ?longitude ; dbpprop

Can't retrieve movies with high IDs from LinkedMDB with SPARQL

折月煮酒 提交于 2019-12-19 08:52:24
问题 I'm running the following query at the LinkedMDB SPARQL endpoint and it works. With it, I get all the information that I need about the director of the movie with id 72, which is Titanic , so I get information about James Cameron. PREFIX mdb: <http://data.linkedmdb.org/resource/movie/> SELECT ?director?nombre_director?id_director WHERE { ?pelicula mdb:filmid ?id . ?pelicula <http://data.linkedmdb.org/resource/movie/director> ?director . ?director <http://data.linkedmdb.org/resource/movie

How I can use Fuseki with Jena TDB

三世轮回 提交于 2019-12-19 04:05:01
问题 I have a question for you. I have a triplestore "Jena TDB" and I have read that I can set up a SPARQL endpoint for locally stored RDF data. In particular, I saw that in the literature together with Jena TDB is used Fuseki. I loaded my files rdf in Jena TDB in this way: public void store(){ String directory = "C:\\tdb"; String source = "C:\\file1.rdf"; String source1 = "C:\\file2.rdf"; Dataset dataset = openTDB(directory); Model tdb = loadModel(source, dataset); dataset.addNamedModel("File1",

Find lists containing ALL values in a set?

試著忘記壹切 提交于 2019-12-19 03:16:08
问题 How can I find lists that contain each of a set of items in SPARQL? Let's say I have this data: <http://foo.org/test> <http://foo.org/name> ( "new" "fangled" "thing" ) . <http://foo.org/test2> <http://foo.org/name> ( "new" "york" "city" ) . How can I find the items whose lists contain both "new" and "york"? The following SPARQL doesn't work, since filter works on each binding of ?t , not the set of all of them. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?s ?p WHERE { ?s

retrieving the class name of a specific subclass in owl

此生再无相见时 提交于 2019-12-18 09:32:47
问题 I am an rdflib beginner, i have an ontology with classes and sub-classes and I need to look for a specific word in a subclass and, if it is found, return its class name. I have the following code: import rdflib from rdflib import plugin from rdflib.graph import Graph g = Graph() g.parse("test.owl") from rdflib.namespace import Namespace plugin.register( 'sparql', rdflib.query.Processor, 'rdfextras.sparql.processor', 'Processor') plugin.register( 'sparql', rdflib.query.Result, 'rdfextras

How to resolve the execution limits in Linkedmdb

痴心易碎 提交于 2019-12-18 09:04:59
问题 I was trying to extract all movies from Linkedmdb. I used OFFSET to make sure I wont hit the maximum number of results per query. I used the following scrip in python """ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX movie: <http://data.linkedmdb.org/resource/movie/> SELECT distinct ?film WHERE { ?film a movie:film . } LIMIT 1000 OFFSET %s """ %i I looped 5 times, with offsets being 0,1000,2000,3000,4000 and recorded the number of results. It was (1000,1000,500,0,0). I already

SPARQL query to get only results with the most recent date

半世苍凉 提交于 2019-12-18 08:46:17
问题 I am learning basics of SPARQL with recent RDF-database released by the Finnish Ministry of Justice. It contains Finnish law data. There are statutes, which have versions, which have a date and topics. I want to get the most recent versions that have a "gun" topic. So, I wrote this: PREFIX sfl: <http://data.finlex.fi/schema/sfl/> PREFIX eli: <http://data.europa.eu/eli/ontology#> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>