https://github.com/gatenlp/sesamesparql
Query a SPARQL Endpoint and Retrieve Result as a TSV file
https://github.com/gatenlp/sesamesparql
cli command-line-tool openrdf sparql sparql-query tsv
Last synced: 20 days ago
JSON representation
Query a SPARQL Endpoint and Retrieve Result as a TSV file
- Host: GitHub
- URL: https://github.com/gatenlp/sesamesparql
- Owner: GateNLP
- Created: 2020-05-25T10:07:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-03T18:47:10.000Z (over 1 year ago)
- Last Synced: 2025-03-09T19:52:49.722Z (about 1 year ago)
- Topics: cli, command-line-tool, openrdf, sparql, sparql-query, tsv
- Language: Java
- Size: 2.24 MB
- Stars: 0
- Watchers: 12
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tool for Accessing a SPARQL endpoint and fetching query results from there.
Simple API and command line tool to retrieve the result of SPARQL queries from a
Sesame repository.
The tool can be used to retrieve large result sets without overwhelming the server by retrieving
small batches of data (see option -b below) and allows to increase the maxmimum query timeout
for queries over a large repository.
## Setup
* clone the repository and change into the directory
* run `mvn package`
This creates a single jar in `./target` which contains all the dependencies.
## Usage
Run the command:
```
./bin/query.sh -u -i [OTHEROPTIONS]
```
The result rows are written to standard output.
To get usage information:
```
./bin/query.sh -h
```
This outputs:
```
usage: ./bin/query.sh [options]
-b Batchsize for queries, default: retrieve all at once
-ee error on invalid strings: true or false, default=false
-h Show help information
-i Query input file (required)
-ii include inferred: true or false, default=true
-mt maximum query time in seconds, default=3600
-ph print headers: true or false, default=false
-u endpoint URL (required)
```
### Examples
Query DBPedia and get the URI and English language film title of films starring Charlie Chaplin:
Query file `examples/example2.sparql`:
```
PREFIX dbo:
PREFIX res:
PREFIX rdf:
PREFIX rdfs:
SELECT DISTINCT ?uri ?string
WHERE {
?uri rdf:type dbo:Film .
?uri dbo:starring res:Charlie_Chaplin .
OPTIONAL {?uri rdfs:label ?string . FILTER (lang(?string) = 'en') }
}
```
Run the command to retrieve the result, write to file `chaplin_films.tsv` with column headers:
```
./bin/query.sh -ph true -u http://DBpedia.org/sparql -i examples/example2.sparql > chaplin_films.tsv
```