Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I test my queries for my RDF written in SPARQL

Tags:

I am a beginner with Semantic Web technologies, My question might be a very basic one but I am really stuck figuring it out. I have a RDF file I created from an XML and have validated it using w3.org RDF VALIDATOR. My question is how can I run queries on my RDF document using SPARQL. The online resource http://demo.openlinksw.com/sparql does not work and I have no Idea what or how to find information about this.

like image 529
Yaba Avatar asked Dec 16 '12 01:12

Yaba


People also ask

How do I query using SPARQL?

A SPARQL query may specify the dataset to be used for matching by using the FROM clause and the FROM NAMED clause to describe the RDF dataset. If a query provides such a dataset description, then it is used in place of any dataset that the query service would use if no dataset description is provided in a query.

How do I query DBpedia with SPARQL?

To actually query DBpedia, you can go to dbpedia.org/sparql and submit your query to return the results in a number of formats such as HTML, JSON or CSV. You can also run SPARQL on DBpedia from within a Python application but that will be covered in my next blog.


2 Answers

You could set up your own local SPARQL endpoint using Fuseki. Fuseki is part of the Apache Jena Project but can be downloaded as a standalone application (at the link above).

With Fuseki you can (amongst other stuff)

  1. load a local RDF dataset
  2. use that dataset to
    • expose this data as a SPARQL endpoint via http://localhost:3030/ (by default)
    • use a web based query form at http://localhost:3030/sparql.html

That means you can use Fuseki to either simply query your dataset using the web based form or to query your dataset using any application that queries SPARQL endpoints over http.

Personally, I am currently developing an application that analyses datasets via SPARQL endpoints. I use Fuseki to set up a local SPARQL endpoint with example data that I can run and test my application against.


How?

Fuseki's basic functionality is rather easy to use. The line below will start the server (SPARQL endpoint).

java -jar fuseki-server.jar --config=yourConfig.ttl

The file yourConfig.ttl is a RDF file (in turtle serialization format). To set up a basic server that loads your RDF file to memory just write (replacing at least the path to your dataset file):

# Attention: I have omitted the @prefix declarations

[] rdf:type fuseki:Server ;
   fuseki:services (
 <#yourService>
) .

<#yourService> rdf:type fuseki:Service ;
fuseki:name                     "yourService" ;
fuseki:serviceQuery             "query" ;
fuseki:serviceReadGraphStore    "get" ;
fuseki:dataset                   <#yourDataset> ;
.

<#yourDataset>    rdf:type ja:RDFDataset ;
rdfs:label "a label for your dataset" ;
ja:defaultGraph 
  [ rdfs:label "yourDataset.rdf" ;
    a ja:MemoryModel ;
    ja:content [ja:externalContent <file:Path/To/yourDataset.rdf> ] ;
  ] ;
.

like image 126
Thomas Avatar answered Oct 01 '22 14:10

Thomas


There are several tools you can use to do this. Of course, there are the RDF frameworks like Apache Jena or OpenRDF Sesame (Java), or dotNetRdf (.Net), to name just three. Most if not all offer installation and getting started instructions. These are powerful solutions that you will definitely need if you go further with SW technologies and need to build your own code on top of RDF data sources.

But for trying out some simple queries, it's perhaps easier to try something like the Sesame Windows Client (SWC) tool. This is a simple graphical Windows desktop application that you can use to create a repository, load data in it, and then do SPARQL queries, without any programming or advanced configuration (disclaimer: I wrote this tool).

like image 33
Jeen Broekstra Avatar answered Oct 01 '22 14:10

Jeen Broekstra