├── unsorted-tests
├── output.ttl
├── triples.ttl
├── README.md
├── quads.trig
├── iotest.sh
├── sorted-service.sparql
├── service-test.sparql
├── service-test-all-triples.sparql
└── iotest.nt
├── docs
├── examples
│ ├── test.nt
│ ├── data.csv
│ ├── example-data
│ │ ├── data.csv
│ │ ├── people.csv
│ │ └── data.ttl
│ ├── hashbang.sparql
│ ├── json-hello-world.sparql
│ ├── json-by-index.sparql
│ ├── json-unnest.sparql
│ ├── fs-list-all-files.sparql
│ ├── json-path-inline.sparql
│ ├── json-unnest-by-index.sparql
│ ├── url-local-file.sparql
│ ├── json-path1.sparql
│ ├── fs-test.sparql
│ ├── macro-example.sh
│ ├── fs-list-rdf-files.sparql
│ ├── test4.sparql
│ ├── xml-unnest.sparql
│ ├── test.sparql
│ ├── test3.sparql
│ ├── test2.sparql
│ ├── fs-query-rdf-files.sparql
│ ├── xml-attribute.sparql
│ ├── csv.sparql
│ ├── io.sparql
│ ├── workloads.sparql
│ ├── macros.ttl
│ ├── json-zip-arrays.sparql
│ └── test-zip-arrays.sparql
├── README.md
├── images
│ ├── 2024-09-27-demo-leaflet-screenshot.png
│ └── 2024-09-27-demo-wikidata-movie-browser-screenshot.png
├── Gemfile
├── demos
│ ├── movies
│ │ ├── query.rq
│ │ └── query.qgl
│ └── leaflet-graphql
│ │ └── query-countries.rq
├── sparql-extensions
│ ├── service-enhancer.md
│ ├── function-extensions.md
│ ├── index.md
│ └── macros.md
├── sansa
│ └── README.md
├── publications
│ └── index.md
├── graphql
│ ├── index.md
│ ├── demo.md
│ ├── README.md
│ └── reference
│ │ ├── bind.md
│ │ ├── prefix.md
│ │ ├── pattern.md
│ │ ├── join.md
│ │ └── one-and-many.md
├── _config.yml
├── rml
│ └── index.md
├── integrate
│ ├── canned-queries.md
│ └── engines.md
├── getting-started
│ └── index.md
├── index.md
└── Gemfile.lock
├── rdf-processing-toolkit-bundle
└── .gitignore
├── rdf-processing-toolkit-cli
└── src
│ ├── main
│ ├── resources
│ │ ├── s.rq
│ │ ├── spo.rq
│ │ ├── gspo.rq
│ │ ├── count.rq
│ │ ├── bnode-test.rq
│ │ ├── test-transpose.rq
│ │ ├── path-test.rq
│ │ ├── spogspo.rq
│ │ ├── rename.rq
│ │ ├── property-joins.rq
│ │ ├── env-test.rq
│ │ ├── gtree.rq
│ │ ├── tree.rq
│ │ ├── shacl-targetClass.rq
│ │ ├── log4j2.yaml.template.bak
│ │ ├── examples
│ │ │ └── udf.ttl
│ │ └── log4j2.properties
│ ├── java
│ │ ├── org
│ │ │ └── aksw
│ │ │ │ ├── named_graph_stream
│ │ │ │ └── cli
│ │ │ │ │ ├── main
│ │ │ │ │ ├── NamedGraphFluent.java
│ │ │ │ │ ├── QueryEvaluatorForTuple.java
│ │ │ │ │ ├── DatasetFlowOps.java
│ │ │ │ │ └── NamedGraphStreamOps.java
│ │ │ │ │ └── cmd
│ │ │ │ │ ├── CmdNgJoin.java
│ │ │ │ │ ├── CmdNgsMain.java
│ │ │ │ │ ├── CmdNgsCat.java
│ │ │ │ │ ├── IParameterConsumerFlaggedLong.java
│ │ │ │ │ ├── CmdNgsSubjects.java
│ │ │ │ │ ├── CmdNgsMerge.java
│ │ │ │ │ ├── CmdNgsGit.java
│ │ │ │ │ ├── CmdNgsProbe.java
│ │ │ │ │ ├── CmdNgsWhile.java
│ │ │ │ │ ├── CmdNgsUntil.java
│ │ │ │ │ ├── CmdNgsWc.java
│ │ │ │ │ ├── CmdNgsTail.java
│ │ │ │ │ ├── CmdNgsFilter.java
│ │ │ │ │ ├── CmdNgsHead.java
│ │ │ │ │ ├── CmdNgsMap.java
│ │ │ │ │ └── CmdNgsSort.java
│ │ │ │ ├── rdf_processing_toolkit
│ │ │ │ └── cli
│ │ │ │ │ ├── cmd
│ │ │ │ │ ├── HasDebugMode.java
│ │ │ │ │ ├── graphql
│ │ │ │ │ │ └── CmdGraphQlTkParent.java
│ │ │ │ │ ├── RptCmdUtils.java
│ │ │ │ │ ├── CmdCommonBase.java
│ │ │ │ │ ├── VersionProviderRdfProcessingToolkit.java
│ │ │ │ │ ├── CmdMixinSparqlDataset.java
│ │ │ │ │ ├── CmdRptMain.java
│ │ │ │ │ └── VersionProviderFromClasspathProperties.java
│ │ │ │ │ └── main
│ │ │ │ │ ├── MainCliRdfProcessingToolkit.java
│ │ │ │ │ └── MainCliRdfProcessingToolkitBase.java
│ │ │ │ ├── sparql_integrate
│ │ │ │ ├── cli
│ │ │ │ │ ├── DerbyUtil.java
│ │ │ │ │ ├── cmd
│ │ │ │ │ │ ├── ConverterDuration.java
│ │ │ │ │ │ └── CmdRptServe.java
│ │ │ │ │ ├── main
│ │ │ │ │ │ ├── MainCliSparqlIntegrate.java
│ │ │ │ │ │ ├── MainPlaygroundDataset.java
│ │ │ │ │ │ ├── SansaQueryRewrite.java
│ │ │ │ │ │ ├── ClassPathResourceResolver.java
│ │ │ │ │ │ └── ServletLdvConfigJs.java
│ │ │ │ │ ├── CommandMain.java
│ │ │ │ │ ├── MainCliSparqlLoad.java
│ │ │ │ │ └── SparqlStmtProcessor.java
│ │ │ │ └── web
│ │ │ │ │ └── servlet
│ │ │ │ │ └── ServletGraphQlSchema.java
│ │ │ │ ├── sparql_binding_stream
│ │ │ │ └── cli
│ │ │ │ │ ├── main
│ │ │ │ │ └── MainCliSparqlBindingStream.java
│ │ │ │ │ └── cmd
│ │ │ │ │ ├── CmdSbsMain.java
│ │ │ │ │ ├── CmdSbsSplit.java
│ │ │ │ │ ├── CmdSbsFilter.java
│ │ │ │ │ └── CmdSbsMap.java
│ │ │ │ ├── jena_sparql_api
│ │ │ │ └── rx
│ │ │ │ │ └── op
│ │ │ │ │ └── api
│ │ │ │ │ ├── OpConfigSort.java
│ │ │ │ │ └── OpConfigSortImpl.java
│ │ │ │ └── rml
│ │ │ │ └── v2
│ │ │ │ └── cli
│ │ │ │ └── main
│ │ │ │ └── CmdRml2Exec.java
│ │ ├── ngs.java
│ │ ├── sbs.java
│ │ ├── rpt.java
│ │ └── integrate.java
│ └── resources-filtered
│ │ └── rdf-processing-toolkit.properties
│ └── test
│ ├── resources
│ ├── test-used-prefixes.sparql
│ ├── ngs
│ │ └── ngs-map.sparql
│ ├── base-uri-test-data.trig
│ ├── ngs-nato-phonetic-alphabet-single-graph.nq
│ ├── ngs-nato-phonetic-alphabet-single-graph.trig
│ ├── js-query-3.srj
│ ├── namespace-test.sparql
│ ├── fix-geom.sparql
│ ├── ngs-nato-phonetic-alphabet.trig
│ └── test-geosparql-remote.sparql
│ └── java
│ └── org
│ └── aksw
│ └── sparql_integrate
│ └── ngs
│ └── cli
│ └── main
│ ├── TestCliNgs.java
│ └── TestSparqlBindingStreamOperators.java
├── use-case-sportal-analysis
├── src
│ └── main
│ │ └── resources
│ │ ├── qa1.rq
│ │ ├── qc1.rq
│ │ ├── qa2.rq
│ │ ├── qd1.rq
│ │ ├── qb1.rq
│ │ ├── qb2.rq
│ │ ├── qb4.rq
│ │ ├── qb5.rq
│ │ ├── qb3.rq
│ │ ├── qe1.rq
│ │ ├── qf4.rq
│ │ ├── compact
│ │ ├── qx1.rq
│ │ ├── qf3.rq
│ │ ├── qb2.rq
│ │ ├── qf1.rq
│ │ ├── qf4.rq
│ │ ├── qf2.rq
│ │ ├── qf5.rq
│ │ ├── qf6.rq
│ │ ├── qf8.rq
│ │ ├── qf7.rq
│ │ ├── qc5.rq
│ │ ├── qc3.rq
│ │ ├── qbAllBut2.rq
│ │ ├── qdAll.rq
│ │ ├── qcAllBut35.rq
│ │ ├── qf9.rq
│ │ ├── qf10.rq
│ │ └── qeAll.rq
│ │ ├── qf3.rq
│ │ ├── qf5.rq
│ │ ├── qc2.rq
│ │ ├── qd2.rq
│ │ ├── qf1.rq
│ │ ├── qc3.rq
│ │ ├── qf6.rq
│ │ ├── qc4.rq
│ │ ├── qd4.rq
│ │ ├── qf2.rq
│ │ ├── qf8.rq
│ │ ├── qd3.rq
│ │ ├── qe3.rq
│ │ ├── qf7.rq
│ │ ├── qc5.rq
│ │ ├── qe4.rq
│ │ ├── qe2.rq
│ │ ├── qf10.rq
│ │ ├── qf9.rq
│ │ ├── qc6.rq
│ │ └── log4j.properties
└── pom.xml
├── rdf-processing-toolkit-pkg-parent
├── rdf-processing-toolkit-pkg-deb-cli
│ ├── .gitignore
│ └── src
│ │ └── deb
│ │ ├── resources
│ │ └── usr
│ │ │ └── bin
│ │ │ ├── voidgen
│ │ │ ├── sparql-load
│ │ │ └── rpt
│ │ └── control
│ │ ├── control
│ │ └── copyright
├── rdf-processing-toolkit-pkg-rpm-cli
│ └── src
│ │ └── rpm
│ │ └── resources
│ │ └── usr
│ │ └── bin
│ │ └── rpt
├── rdf-processing-toolkit-pkg-dummy
│ └── pom.xml
├── pom.xml
└── rdf-processing-toolkit-pkg-docker-cli
│ └── pom.xml
├── .github
├── dependabot.yml
└── workflows
│ ├── ci.yml
│ └── pages.yml
├── reinstall-debs.sh
├── output.dat
├── ngs
├── ngs-create-test-data.sh
├── even.sparql
├── hash.sparql
└── ngs-benchmark.sh
├── sportal
├── sportal-qb2.sparql
├── sportal-qe2-mem.sparql
├── sportal-qf10.sparql
└── sportal-qe2.sparql
├── .gitignore
├── NOTES.md
├── bitmask.sparql
├── example.sparql
├── rdf-processing-toolkit-web-service
└── pom.xml
├── README-SBS.md
├── setup-latest-release.sh
├── Makefile
├── README.md
└── macros
└── macros-ollama.ttl
/unsorted-tests/output.ttl:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/examples/test.nt:
--------------------------------------------------------------------------------
1 |
.
2 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-bundle/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/docs/examples/data.csv:
--------------------------------------------------------------------------------
1 | fn,ln
2 | Mary,Major
3 | John,Doe
4 |
--------------------------------------------------------------------------------
/docs/examples/example-data/data.csv:
--------------------------------------------------------------------------------
1 | "a","b"
2 | "c","d"
3 |
--------------------------------------------------------------------------------
/docs/examples/example-data/people.csv:
--------------------------------------------------------------------------------
1 | fn,ln
2 | Mary,Major
3 | John,Doe
4 |
--------------------------------------------------------------------------------
/docs/examples/hashbang.sparql:
--------------------------------------------------------------------------------
1 | #!/usr/bin/sparql-integrate
2 |
3 |
4 | SELECT 1 { }
5 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/s.rq:
--------------------------------------------------------------------------------
1 | SELECT DISTINCT ?s { ?s ?p ?o }
2 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/spo.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT WHERE { ?s ?p ?o }
2 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qa1.rq:
--------------------------------------------------------------------------------
1 | SELECT * WHERE { ?s ?p ?o } LIMIT 1
--------------------------------------------------------------------------------
/rdf-processing-toolkit-pkg-parent/rdf-processing-toolkit-pkg-deb-cli/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/unsorted-tests/triples.ttl:
--------------------------------------------------------------------------------
1 | @prefix t: .
2 | t:s t:p t:o
3 |
--------------------------------------------------------------------------------
/unsorted-tests/README.md:
--------------------------------------------------------------------------------
1 | Tests resources that need yet to be turned into proper unit testsg
2 |
--------------------------------------------------------------------------------
/docs/examples/example-data/data.ttl:
--------------------------------------------------------------------------------
1 | @prefix eg:
2 | eg:s eg:p eg:o .
3 |
4 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/gspo.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT WHERE { GRAPH ?g { ?s ?p ?o } }
2 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | ## This page will become the new documentation for the RdfProcessingToolkit (RPT)
2 |
3 |
--------------------------------------------------------------------------------
/docs/examples/json-hello-world.sparql:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | BIND('{"hello": "world"}'^^xsd:json AS ?s)
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/docs/examples/json-by-index.sparql:
--------------------------------------------------------------------------------
1 |
2 | SELECT * {
3 | '[true, 1, "hi"]'^^xsd:json json:unnest (?item 2)
4 | }
5 |
--------------------------------------------------------------------------------
/unsorted-tests/quads.trig:
--------------------------------------------------------------------------------
1 | @prefix q: .
2 | q:a q:b q:c .
3 | q:w { q:x q:y q:z }
4 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qc1.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:classPartition [ v:class ?c ] } WHERE { ?s a ?c }
--------------------------------------------------------------------------------
/docs/examples/json-unnest.sparql:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | '[true, 1, "hi", {}, []]'^^xsd:json json:unnest (?item ?index)
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qa2.rq:
--------------------------------------------------------------------------------
1 | SELECT (COUNT(*) as ?c) {
2 | SELECT * WHERE { ?s ?p ?o } LIMIT 1
3 | }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qd1.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:propertyPartition [ v:property ?p ] } WHERE { ?s ?p ?o }
--------------------------------------------------------------------------------
/docs/examples/fs-list-all-files.sparql:
--------------------------------------------------------------------------------
1 | #!/usr/bin/sparql-integrate
2 |
3 | SELECT * {
4 | fs:find ?file
5 | }
6 |
--------------------------------------------------------------------------------
/docs/examples/json-path-inline.sparql:
--------------------------------------------------------------------------------
1 | SELECT ?s {
2 | BIND(json:path('{"hello": "world"}'^^xsd:json, "$.hello") AS ?s)
3 | }
4 |
--------------------------------------------------------------------------------
/docs/examples/json-unnest-by-index.sparql:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | '[true, 1, "hi", {}, []]'^^xsd:json json:unnest (?item 2)
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/test/resources/test-used-prefixes.sparql:
--------------------------------------------------------------------------------
1 | INSERT DATA {
2 | eg:s rdfs:label "Foobar" .
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/count.rq:
--------------------------------------------------------------------------------
1 | SELECT (COUNT(*) AS ?c) { { ?s ?p ?o } UNION { GRAPH ?g { ?s ?p ?o } } }
2 |
3 |
--------------------------------------------------------------------------------
/docs/examples/url-local-file.sparql:
--------------------------------------------------------------------------------
1 | #!/usr/bin/sparql-integrate
2 |
3 | SELECT * {
4 | url:text ?str
5 | }
6 |
7 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/bnode-test.rq:
--------------------------------------------------------------------------------
1 | SELECT * { SERVICE { ?s ?p ?o FILTER(isBlANK(?s)) } }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qb1.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 | v:triples ?x
3 | } {
4 | SELECT (COUNT(*) AS ?x) WHERE { ?s ?p ?o }
5 | }
--------------------------------------------------------------------------------
/docs/examples/json-path1.sparql:
--------------------------------------------------------------------------------
1 | SELECT ?s {
2 | BIND('{"hello": "world"}'^^xsd:json AS ?str)
3 | BIND(json:path(?str, "$.hello") AS ?s)
4 | }
5 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qb2.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:classes ?x } {
2 | SELECT (COUNT(DISTINCT ?o) AS ?x) WHERE { ?s a ?o }
3 | }
4 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qb4.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:distinctSubjects ?x }WHERE { SELECT (COUNT(DISTINCT ?s) AS ?x) WHERE { ?s ?p ?o } }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qb5.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:distinctObjects ?x }WHERE { SELECT (COUNT(DISTINCT ?o) AS ?x) WHERE { ?s ?p ?o } }
--------------------------------------------------------------------------------
/docs/examples/fs-test.sparql:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | fs:find ?file
3 | FILTER(fs:probeRdf(?file))
4 | SERVICE ?file {
5 | ?s ?p ?o
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/docs/examples/macro-example.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | rpt integrate --macro macros.ttl 'SELECT (eg:greet("John Doe") AS ?x) {}' --out-format tsv | tail -n1
4 |
5 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qb3.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 | v:properties ?x
3 | } {
4 | SELECT (COUNT(DISTINCT ?p) AS ?x) WHERE { ?s ?p ?o }
5 | }
--------------------------------------------------------------------------------
/docs/examples/fs-list-rdf-files.sparql:
--------------------------------------------------------------------------------
1 | #!/usr/bin/sparql-integrate
2 |
3 | SELECT * {
4 | fs:find ?file
5 | FILTER(fs:probeRdf(?file))
6 | }
7 |
--------------------------------------------------------------------------------
/docs/examples/test4.sparql:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | <> fs:find ?file
3 | FILTER(REGEX(STR(?file), '\\.ttl$', 'i'))
4 | SERVICE ?file {
5 | ?s ?p ?o
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/docs/images/2024-09-27-demo-leaflet-screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Scaseco/RdfProcessingToolkit/HEAD/docs/images/2024-09-27-demo-leaflet-screenshot.png
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qe1.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:classPartition [ v:class ?c ; v:propertyPartition [ v:property ?p ] ] }WHERE { ?s a ?c ; ?p ?o }
--------------------------------------------------------------------------------
/docs/examples/xml-unnest.sparql:
--------------------------------------------------------------------------------
1 | #!/usr/bin/sparql-integrate
2 |
3 | SELECT * {
4 | """"""^^xsd:xml xml:unnest ("//li" ?item)
5 | }
6 |
7 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/test/resources/ngs/ngs-map.sparql:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 | .
3 | }
4 | {
5 | ?s ?p ?o
6 | }
7 |
8 |
--------------------------------------------------------------------------------
/docs/examples/test.sparql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | FROM
3 | {
4 | ?s ?p ?o
5 | }
6 |
7 | #SELECT * {
8 | # SERVICE {
9 | # ?s ?p ?o
10 | # }
11 | #}
12 |
--------------------------------------------------------------------------------
/unsorted-tests/iotest.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | sparql-integrate --io=iotest.nt <(echo 'INSERT { eg:a eg:b ?c } WHERE { { SELECT (COUNT(*) AS ?c) { ?s ?p ?o } } }') spo.sparql
3 |
4 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qf4.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { e:distinctLiterals ?x } WHERE { SELECT (COUNT(DISTINCT ?o ) AS ?x) WHERE { ?s ?p ?o FILTER(isLiteral(?o))} }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qx1.rq:
--------------------------------------------------------------------------------
1 |
2 | # Declare the placeholder to be a void dataset
3 | CONSTRUCT {
4 | a void:Dataset
5 | }
6 | {
7 | }
8 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qf3.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { e:distinctIRIReferenceObjects ?x } {
2 | SELECT (COUNT(DISTINCT ?o ) AS ?x) { ?s ?p ?o FILTER(isIri(?o)) }
3 | }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qf5.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { e:distinctBlankNodeObjects ?x } {
2 | SELECT (COUNT(DISTINCT ?o ) AS ?x) WHERE { ?s ?p ?o FILTER(isBlank(?o)) }
3 | }
--------------------------------------------------------------------------------
/docs/examples/test3.sparql:
--------------------------------------------------------------------------------
1 | SELECT *
2 | FROM {
3 | ?s ?p ?o
4 | }
5 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qc2.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:classPartition [ v:class ?c ; v:triples ?x ] }WHERE { SELECT (COUNT(?p) AS ?x) ?c WHERE { ?s a ?c ; ?p ?o } GROUP BY ?c }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qd2.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:propertyPartition [ v:property ?p ; v:triples ?x ] }WHERE { SELECT (COUNT(?o) AS ?x) ?p WHERE { ?s ?p ?o } GROUP BY ?p }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qf1.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { e:distinctIRIReferenceSubjects ?x } {
2 | SELECT (COUNT(DISTINCT ?s ) AS ?x) WHERE { ?s ?p ?o FILTER(isIri(?s)) }
3 | }
--------------------------------------------------------------------------------
/docs/images/2024-09-27-demo-wikidata-movie-browser-screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Scaseco/RdfProcessingToolkit/HEAD/docs/images/2024-09-27-demo-wikidata-movie-browser-screenshot.png
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/test/resources/base-uri-test-data.trig:
--------------------------------------------------------------------------------
1 | @base .
2 | @prefix : .
3 |
4 | .
5 | :x :y :z .
6 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qc3.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:classPartition [ v:class ?c ; v:classes ?x ] }WHERE { SELECT (COUNT(DISTINCT ?d) AS ?x) ?c WHERE { ?s a ?c , ?d } GROUP BY ?c }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qf6.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { e:distinctBlankNodes ?x }WHERE { SELECT (COUNT(DISTINCT ?b ) AS ?x)WHERE { { ?s ?p ?b } UNION { ?b ?p ?o } FILTER(isBlank(?b)) } }
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: bundler
4 | directory: /
5 | schedule:
6 | interval: daily
7 | allow:
8 | - dependency-type: direct
9 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/main/NamedGraphFluent.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.main;
2 |
3 | public interface NamedGraphFluent {
4 | }
5 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources-filtered/rdf-processing-toolkit.properties:
--------------------------------------------------------------------------------
1 | rdf-processing-toolkit.version=${project.version}
2 | rdf-processing-toolkit.build.timestamp=${timestamp}
3 |
4 |
--------------------------------------------------------------------------------
/reinstall-debs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | cd "$(dirname "$0")"
3 |
4 | p1=`find rdf-processing-toolkit-pkg-parent/rdf-processing-toolkit-pkg-deb-cli/target | grep '\.deb$'`
5 |
6 | sudo dpkg -i "$p1"
7 |
8 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qc4.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:classPartition [ v:class ?c ; v:properties ?x ] }WHERE { SELECT (COUNT(DISTINCT ?p) AS ?x) ?c WHERE { ?s a ?c ; ?p ?o } GROUP BY ?c }
--------------------------------------------------------------------------------
/docs/examples/test2.sparql:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | SERVICE {
3 | ?s ?p ?o
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qd4.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:propertyPartition [ v:property ?p ; v:distinctObjects ?x ] }WHERE { SELECT (COUNT(DISTINCT ?o) AS ?x) ?p WHERE { ?s ?p ?o } GROUP BY ?p }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qf2.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 | e:distinctBlankNodeSubjects ?x
3 | } {
4 | SELECT (COUNT(DISTINCT ?s) AS ?x) {
5 | ?s ?p ?o FILTER(isBlank(?s))
6 | }
7 | }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qf8.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 | e:distinctRDFNodes ?x
3 | }
4 | {
5 | SELECT (COUNT(DISTINCT ?n ) AS ?x) { { ?n ?p ?o } UNION { ?s ?n ?o } UNION { ?s ?p ?n } }
6 | }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qd3.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:propertyPartition [ v:property ?p ; v:distinctSubjects ?x ] } {
2 | SELECT (COUNT(DISTINCT ?s) AS ?x) ?p WHERE { ?s ?p ?o } GROUP BY ?p
3 | }
--------------------------------------------------------------------------------
/output.dat:
--------------------------------------------------------------------------------
1 | @prefix xsd: .
2 | @prefix void: .
3 |
4 | void:classes 193 ;
5 | void:distinctBlankNodeSubjects 3 .
6 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/test-transpose.rq:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | VALUES (?x ?y) { ("a" "b") ("c" "d") }
3 |
4 | OPTIONAL { BIND(?x AS ?v) }
5 | #UNION { BIND(?y AS ?v) }
6 | #}
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/docs/examples/fs-query-rdf-files.sparql:
--------------------------------------------------------------------------------
1 | #!/usr/bin/sparql-integrate
2 |
3 | SELECT * {
4 | fs:find ?file
5 | FILTER(fs:probeRdf(?file))
6 | SERVICE ?file {
7 | ?s ?p ?o
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/path-test.rq:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | BIND(fs:get('tmp') AS ?w)
3 | BIND(fs:get('/tmp') AS ?x)
4 | BIND(fs:get() AS ?y)
5 | BIND(fs:get() AS ?z)
6 | }
7 |
--------------------------------------------------------------------------------
/ngs/ngs-create-test-data.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | MAX=${1:-10}
4 |
5 | echo "@prefix eg: ."
6 | for i in `seq 1 $MAX`; do
7 | echo " { eg:idx $i }"
8 | done
9 |
10 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/rdf_processing_toolkit/cli/cmd/HasDebugMode.java:
--------------------------------------------------------------------------------
1 | package org.aksw.rdf_processing_toolkit.cli.cmd;
2 |
3 | public interface HasDebugMode {
4 | boolean isDebugMode();
5 | }
6 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/main/QueryEvaluatorForTuple.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.main;
2 |
3 | public interface QueryEvaluatorForTuple {
4 | int getArity();
5 | }
6 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qe3.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:classPartition [ v:class ?c ;v:propertyPartition [ v:distinctSubjects ?x ] ] }WHERE { SELECT (COUNT(DISTINCT ?s) AS ?x) ?c ?p WHERE { ?s a ?c ; ?p ?o } GROUP BY ?c ?p }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qf7.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 | e:distinctIRIReferences ?x
3 | } {
4 | SELECT (COUNT(DISTINCT ?u ) AS ?x) {
5 | { ?u ?p ?o } UNION { ?s ?u ?o } UNION { ?s ?p ?u } FILTER(isIri(?u))
6 | }
7 | }
--------------------------------------------------------------------------------
/docs/examples/xml-attribute.sparql:
--------------------------------------------------------------------------------
1 | #!/usr/bin/sparql-integrate
2 |
3 | SELECT * {
4 | BIND(''^^xsd:xml AS ?xml)
5 | BIND(xml:path(?xml, "//ul/@id") AS ?id)
6 | BIND(xml:path(?xml, "//li") AS ?item)
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qf3.rq:
--------------------------------------------------------------------------------
1 | PREFIX s:
2 |
3 | CONSTRUCT {
4 | s:distinctIRIReferenceObjects ?x
5 | } {
6 | SELECT (COUNT(DISTINCT ?o ) AS ?x) { ?s ?p ?o FILTER(isIri(?o)) }
7 | }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qc5.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 |
3 | v:classPartition [
4 | v:class ?c ;
5 | v:distinctSubjects ?x
6 | ]
7 | } {
8 | SELECT (COUNT(DISTINCT ?s) AS ?x) ?c WHERE { ?s a ?c } GROUP BY ?c
9 | }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qe4.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT { v:classPartition [ v:class ?c ;v:propertyPartition [ v:distinctObjects ?x ; v:property ?p ] ] }WHERE { SELECT (COUNT(DISTINCT ?o) AS ?x) ?c ?p WHERE { ?s a ?c ; ?p ?o } GROUP BY ?c ?p }
--------------------------------------------------------------------------------
/docs/examples/csv.sparql:
--------------------------------------------------------------------------------
1 | #!/usr/bin/sparql-integrate
2 |
3 | SELECT * { csv:parse (?rowJson "excel -h") }
4 |
5 | SELECT * {
6 | """fn,ln
7 | Mary,Major
8 | John,Doe""" csv:parse (?rowJson "excel -h")
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qb2.rq:
--------------------------------------------------------------------------------
1 | PREFIX v:
2 |
3 | CONSTRUCT {
4 | v:classes ?x
5 | } {
6 | SELECT
7 | (COUNT(DISTINCT ?o) AS ?x)
8 | {
9 | ?s a ?o
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qe2.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 | v:classPartition [ v:class ?c ; v:propertyPartition [ v:property ?p ; v:triples ?x ] ]
3 | }
4 | {
5 | SELECT (COUNT(?o) AS ?x) ?p WHERE { ?s a ?c ; ?p ?o } GROUP BY ?c ?p
6 | }
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/ngs.java:
--------------------------------------------------------------------------------
1 | import org.aksw.named_graph_stream.cli.main.MainCliNamedGraphStream;
2 |
3 | public class ngs {
4 | public static void main(String[] args) throws Exception {
5 | MainCliNamedGraphStream.main(args);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qf1.rq:
--------------------------------------------------------------------------------
1 | PREFIX s:
2 |
3 | CONSTRUCT {
4 | s:distinctIRIReferenceSubjects ?x
5 | }
6 | {
7 | SELECT (COUNT(DISTINCT ?s ) AS ?x) WHERE { ?s ?p ?o FILTER(isIri(?s)) }
8 | }
9 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/test/resources/ngs-nato-phonetic-alphabet-single-graph.nq:
--------------------------------------------------------------------------------
1 | _:a "Alfa" .
2 | _:a .
3 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qf10.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 | v:propertyPartition [ v:property ?p ; s:objectTypes [ s:objectClass ?oType ; s:distinctMembers ?x ] ]
3 | } { SELECT (COUNT(?o) AS ?x) ?p ?oType WHERE { ?s ?p ?o . ?o a ?oType . } GROUP BY ?p ?oType }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qf4.rq:
--------------------------------------------------------------------------------
1 | PREFIX s:
2 |
3 | CONSTRUCT {
4 | s:distinctLiterals ?x
5 | }
6 | {
7 | SELECT (COUNT(DISTINCT ?o) AS ?x) {
8 | ?s ?p ?o
9 | FILTER(isLiteral(?o))
10 | }
11 | }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qf9.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 | v:propertyPartition [ v:property ?p ;s:subjectTypes [ s:subjectClass ?sType ; s:distinctMembers ?x ] ]
3 | } {
4 | SELECT (COUNT(?s) AS ?x) ?p ?sType WHERE { ?s ?p ?o ; a ?sType . } GROUP BY ?p ?sType
5 | }
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/sbs.java:
--------------------------------------------------------------------------------
1 | import org.aksw.sparql_binding_stream.cli.main.MainCliSparqlBindingStream;
2 |
3 | public class sbs {
4 | public static void main(String[] args) throws Exception {
5 | MainCliSparqlBindingStream.main(args);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/spogspo.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 | GRAPH ?g { ?s ?p ?o }
3 | }
4 | WHERE {
5 | {
6 | BIND( AS ?g)
7 | ?s ?p ?o
8 | }
9 | UNION
10 | {
11 | GRAPH ?g { ?s ?p ?o }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qf2.rq:
--------------------------------------------------------------------------------
1 | PREFIX s:
2 |
3 | CONSTRUCT {
4 | s:distinctBlankNodeSubjects ?x
5 | }
6 | {
7 | SELECT (COUNT(DISTINCT ?s) AS ?x) {
8 | ?s ?p ?o
9 | FILTER(isBlank(?s))
10 | }
11 | }
--------------------------------------------------------------------------------
/docs/examples/io.sparql:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 | ?s eg:value ?o
3 | }
4 | {
5 | {
6 | BIND(1 AS ?o)
7 | }
8 | UNION {
9 | [] eg:value ?y
10 | BIND(?y + 1 AS ?o)
11 | }
12 | BIND(IRI(CONCAT(STR(eg:), 's', STR(?o))) AS ?s)
13 | }
14 |
15 | SELECT * { ?s ?p ?o }
16 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/rpt.java:
--------------------------------------------------------------------------------
1 | import org.aksw.rdf_processing_toolkit.cli.main.MainCliRdfProcessingToolkit;
2 |
3 | public class rpt {
4 | public static void main(String[] args) throws Exception {
5 | MainCliRdfProcessingToolkit.main(args);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/rename.rq:
--------------------------------------------------------------------------------
1 | ## Rename via environment variables
2 | DELETE { ?a ?b ?x . ?x ?c ?d }
3 | INSERT{ ?a ?b ?y . ?y ?c ?d }
4 | WHERE {
5 | ?a ?b ?x . ?x ?c ?d
6 | FILTER(?x = URI(sys:getenv('FROM')))
7 | FILTER(?y = URI(sys:getenv('TO')))
8 | }
9 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/test/resources/ngs-nato-phonetic-alphabet-single-graph.trig:
--------------------------------------------------------------------------------
1 | @prefix foaf: .
2 |
3 |
4 | {
5 | _:a foaf:name "Alfa" .
6 | _:a foaf:mbox .
7 | }
8 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qf5.rq:
--------------------------------------------------------------------------------
1 | PREFIX s:
2 |
3 | CONSTRUCT {
4 | s:distinctBlankNodeObjects ?x
5 | } {
6 | SELECT
7 | (COUNT(DISTINCT ?o) AS ?x)
8 | {
9 | ?s ?p ?o
10 | FILTER(isBlank(?o))
11 | }
12 | }
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgJoin.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | /**
4 | * Join two collections of named graphs by common keys
5 | *
6 | * @author raven
7 | *
8 | */
9 | public class CmdNgJoin {
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/unsorted-tests/sorted-service.sparql:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | SERVICE {
3 | # SERVICE {
4 | ?p ?o
5 | }
6 | }
7 |
8 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/qc6.rq:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 |
3 | v:classPartition [
4 | v:class ?c ;
5 | v:distinctObjects ?x
6 | ]
7 | } {
8 | SELECT ?c (COUNT(DISTINCT ?o) AS ?x) {
9 | ?s
10 | a ?c ;
11 | ?p ?o
12 | } GROUP BY ?c
13 | }
14 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/test/resources/js-query-3.srj:
--------------------------------------------------------------------------------
1 | {
2 | "head": {
3 | "vars": [ "X" ]
4 | } ,
5 | "results": {
6 | "bindings": [
7 | {
8 | "X": { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "10" }
9 | }
10 | ]
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/test/resources/namespace-test.sparql:
--------------------------------------------------------------------------------
1 | #Just a quick check whether namespaces work as expected
2 | # The second query should yield results because it reuses the prior namespace declaration
3 | PREFIX test: INSERT DATA { test:a test:b test:c }
4 |
5 | SELECT * { ?s test:b ?o }
6 |
--------------------------------------------------------------------------------
/ngs/even.sparql:
--------------------------------------------------------------------------------
1 | PREFIX eg:
2 | CONSTRUCT {
3 | GRAPH ?g {
4 | ?s ?p ?o
5 | }
6 | } {
7 | { SELECT * {
8 | GRAPH ?g {
9 | ?s
10 | ?p ?o ;
11 | eg:idx ?key
12 | }
13 | FILTER(ABS(FLOOR(?key * 0.5) - ?key * 0.5) < 0.1)
14 | } ORDER BY ?key ?g }
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qf6.rq:
--------------------------------------------------------------------------------
1 | PREFIX s:
2 |
3 | CONSTRUCT {
4 | s:distinctBlankNodes ?x
5 | }
6 | {
7 | SELECT
8 | (COUNT(DISTINCT ?b ) AS ?x)
9 | {
10 | { ?s ?p ?b }
11 | UNION
12 | { ?b ?p ?o }
13 | FILTER(isBlank(?b))
14 | }
15 | }
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qf8.rq:
--------------------------------------------------------------------------------
1 | PREFIX s:
2 |
3 | CONSTRUCT {
4 | s:distinctRDFNodes ?x
5 | }
6 | {
7 | SELECT (COUNT(DISTINCT ?n ) AS ?x)
8 | {
9 | { ?n ?p ?o }
10 | UNION
11 | { ?s ?n ?o }
12 | UNION
13 | { ?s ?p ?n }
14 | }
15 | }
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/property-joins.rq:
--------------------------------------------------------------------------------
1 | # Create a graph where for each property all joining one's are listed.
2 | # Non-joining properties are not reported
3 | PREFIX ns:
4 | CONSTRUCT {
5 | ?p1 ns:joinsWith ?p2
6 | }
7 | {
8 | SELECT DISTINCT ?p1 ?p2 {
9 | [] ?p1 [ ?p2 [] ]
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/integrate.java:
--------------------------------------------------------------------------------
1 | import org.aksw.rdf_processing_toolkit.cli.cmd.RptCmdUtils;
2 | import org.aksw.sparql_integrate.cli.cmd.CmdSparqlIntegrateMain;
3 |
4 | public class integrate {
5 | public static void main(String[] args) throws Exception {
6 | RptCmdUtils.execCmd(CmdSparqlIntegrateMain.class, args);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qf7.rq:
--------------------------------------------------------------------------------
1 | PREFIX s:
2 |
3 | CONSTRUCT {
4 | s:distinctIRIReferences ?x
5 | } {
6 | SELECT
7 | (COUNT(DISTINCT ?u ) AS ?x)
8 | {
9 | { ?u ?p ?o }
10 | UNION
11 | { ?s ?u ?o }
12 | UNION
13 | { ?s ?p ?u }
14 | FILTER(isIri(?u))
15 | }
16 | }
--------------------------------------------------------------------------------
/docs/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | gem "jekyll", "~> 4.3.3" # installed by `gem jekyll`
4 | # gem "webrick" # required when using Ruby >= 3 and Jekyll <= 4.2.2
5 |
6 | gem "just-the-docs", "0.7.0" # pinned to the current release
7 | # gem "just-the-docs" # always download the latest release
8 |
9 | # gem "jekyll-default-layout"
10 |
11 |
--------------------------------------------------------------------------------
/docs/demos/movies/query.rq:
--------------------------------------------------------------------------------
1 | PREFIX wd:
2 | PREFIX wdt:
3 |
4 | CONSTRUCT {
5 | ?s ?p ?o
6 | }
7 | {
8 | {
9 | ?s wdt:P31 wd:Q11424 .
10 | ?s ?p ?o .
11 | }
12 | UNION
13 | {
14 | ?x wdt:P31 wd:Q11424 .
15 | ?x ?y ?s .
16 | ?s ?p ?o .
17 | }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/ngs/hash.sparql:
--------------------------------------------------------------------------------
1 | PREFIX eg:
2 | CONSTRUCT {
3 | GRAPH ?g {
4 | ?s
5 | ?p ?o ;
6 | eg:hash ?hash
7 | }
8 | } {
9 | { SELECT * {
10 | SELECT ?g ?s ?p ?hash {
11 | GRAPH ?g {
12 | ?s
13 | ?p ?o ;
14 | eg:idx ?key
15 | }
16 | BIND(SHA256(STR(?key)) AS ?hash)
17 | }
18 | } ORDER BY ?key ?g }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/env-test.rq:
--------------------------------------------------------------------------------
1 | #INSERT DATA {
2 | # a
3 | #}
4 |
5 | INSERT {
6 | a
7 | }
8 | WHERE {
9 | ?p ?o
10 | { SELECT ( AS ?x) {
11 | ?p ?o
12 | SERVICE { ?p ?o }
13 | } }
14 | # BIND( AS ?test)
15 | VALUES (?s) { () }
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/sportal/sportal-qb2.sparql:
--------------------------------------------------------------------------------
1 | CONSTRUCT {
2 | #
3 |
4 | void:classes ?x
5 | } WHERE {
6 | { SELECT (COUNT(DISTINCT ?o) AS ?x) {
7 | SERVICE {
8 | # SERVICE {
9 | ?s a ?o
10 | }
11 | } }
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/sportal/sportal-qe2-mem.sparql:
--------------------------------------------------------------------------------
1 | PREFIX v:
2 |
3 | CONSTRUCT {
4 | #
5 |
6 | v:classPartition [
7 | v:class ?c ;
8 | v:propertyPartition [
9 | v:property ?p ;
10 | v:triples ?x
11 | ]
12 | ]
13 | }
14 | WHERE {
15 | { SELECT (COUNT(?o) AS ?x) ?p {
16 | ?s a ?c ; ?p ?o
17 | } GROUP BY ?c ?p }
18 | }
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 | .classpath
3 | .project
4 | .settings
5 | target
6 |
7 | # Package Files #
8 | *.jar
9 | *.war
10 | *.ear
11 |
12 | #Idea files
13 | .idea/
14 | *.iml
15 | *.log
16 |
17 |
18 | pom.xml.releaseBackup
19 | pom.xml.versionsBackup
20 | release.properties
21 |
22 | deptree.txt
23 | felix-cache
24 |
25 | JSA-NOP.tsv
26 | results.tsv
27 |
28 | *.swp
29 |
30 | test-data.trig
31 |
32 | tmp
33 |
34 |
--------------------------------------------------------------------------------
/docs/examples/workloads.sparql:
--------------------------------------------------------------------------------
1 | PREFIX afn:
2 | CONSTRUCT {
3 | [] a eg:Workload ;
4 | rdfs:label ?label ;
5 | eg:file ?file ;
6 | eg:payload ?json .
7 | }
8 | WHERE {
9 | FILTER(STRENDS(STR(?file), "json"))
10 | <> fs:find ?file .
11 | ?file url:text ?str
12 |
13 | BIND(STRDT(?str, xsd:json) AS ?json)
14 |
15 | BIND(afn:localname(?file) AS ?label)
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/docs/sparql-extensions/service-enhancer.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Service Enhancer
3 | parent: SPARQL Extensions
4 | nav_order: 100
5 | layout: default
6 | ---
7 |
8 | # Service Enhancer
9 |
10 | RPT has the [Service Enhancer plugin](https://jena.apache.org/documentation/query/service_enhancer.html) enabled by default. It features combined caching, bulk requests and lateral joins using SPARQL's `SERVICE` clause.
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qc5.rq:
--------------------------------------------------------------------------------
1 | PREFIX v:
2 |
3 | CONSTRUCT {
4 |
5 | v:classPartition ?k .
6 |
7 | ?k
8 | v:class ?t ;
9 | v:distinctSubjects ?a
10 | }
11 | {
12 | SELECT
13 | (IRI(CONCAT(STR(), '/cp/', ENCODE_FOR_URI(STR(?t)))) AS ?k)
14 | ?t
15 | (COUNT(DISTINCT ?s) AS ?a)
16 | {
17 | ?s a ?t
18 | }
19 | GROUP BY ?t
20 | }
21 |
--------------------------------------------------------------------------------
/unsorted-tests/service-test.sparql:
--------------------------------------------------------------------------------
1 | #CONSTRUCT { ?s ?p ?o . GRAPH ?g { ?s ?p ?o } } {
2 | #SELECT * {
3 | INSERT { ?s ?p ?o }
4 | WHERE {
5 | {
6 | SERVICE {
7 | { ?s ?p ?o }
8 | UNION
9 | { GRAPH ?g { ?s ?p ?o } }
10 | }
11 | }
12 | UNION
13 | {
14 | SERVICE {
15 | { ?s ?p ?o }
16 | UNION
17 | { GRAPH ?g { ?s ?p ?o } }
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qc3.rq:
--------------------------------------------------------------------------------
1 | PREFIX v:
2 |
3 | CONSTRUCT {
4 |
5 | v:classPartition ?k .
6 |
7 | ?k
8 | v:class ?t ;
9 | v:classes ?c
10 | }
11 | {
12 | {
13 | SELECT
14 | (IRI(CONCAT(STR(), '/cp/', ENCODE_FOR_URI(STR(?t)))) AS ?k)
15 | ?t
16 | (COUNT(DISTINCT ?o) AS ?c)
17 | {
18 | ?s a ?t , ?o
19 | }
20 | GROUP BY ?t
21 | }
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/unsorted-tests/service-test-all-triples.sparql:
--------------------------------------------------------------------------------
1 | #CONSTRUCT { ?s ?p ?o . GRAPH ?g { ?s ?p ?o } } {
2 | #SELECT * {
3 | INSERT { ?s ?p ?o }
4 | WHERE {
5 | {
6 | SERVICE {
7 | { ?s ?p ?o }
8 | UNION
9 | { GRAPH ?g { ?s ?p ?o } }
10 | }
11 | }
12 | UNION
13 | {
14 | SERVICE {
15 | { ?s ?p ?o }
16 | UNION
17 | { GRAPH ?g { ?s ?p ?o } }
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qbAllBut2.rq:
--------------------------------------------------------------------------------
1 | PREFIX v:
2 |
3 | CONSTRUCT {
4 |
5 | v:triples ?x ;
6 | v:distinctSubjects ?a ;
7 | v:properties ?b ;
8 | v:distinctObjects ?c
9 | }
10 | {
11 | {
12 | SELECT
13 | (COUNT(?s) AS ?x)
14 | (COUNT(DISTINCT ?s) AS ?a)
15 | (COUNT(DISTINCT ?p) AS ?b)
16 | (COUNT(DISTINCT ?o) AS ?c)
17 | {
18 | ?s ?p ?o
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/docs/sansa/README.md:
--------------------------------------------------------------------------------
1 |
2 | # RPT/Sansa
3 |
4 | ## Compressed Output
5 |
6 | Compression using a specific codec can be activated by setting the JVM options `spark.hadoop.mapred.output.compress=true` and `spark.hadoop.mapred.output.compression.codec`.
7 |
8 | ```bash
9 | JAVA_OPTS="-Dspark.hadoop.mapred.output.compress=true -Dspark.hadoop.mapred.output.compression.codec=org.apache.hadoop.io.compress.BZip2Codec" rpt sansa query mapping.rq --out-file out.nt.bz2 --out-overwrite
10 | ```
11 |
12 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/rdf_processing_toolkit/cli/cmd/graphql/CmdGraphQlTkParent.java:
--------------------------------------------------------------------------------
1 | package org.aksw.rdf_processing_toolkit.cli.cmd.graphql;
2 |
3 | import org.aksw.rml.cli.cmd.VersionProviderRmlTk;
4 |
5 | import picocli.CommandLine.Command;
6 |
7 | @Command(name="graphqltk", versionProvider = VersionProviderRmlTk.class, description = "GraphQl Toolkit", subcommands = {
8 | CmdGraphQlSchemaGen.class
9 | })
10 | public class CmdGraphQlTkParent {
11 | }
12 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_integrate/cli/DerbyUtil.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_integrate.cli;
2 |
3 | import java.io.OutputStream;
4 |
5 | // Disable derby.log file - https://stackoverflow.com/questions/1004327/getting-rid-of-derby-log
6 | // System.setProperty("derby.stream.error.field", "${pkg}DerbyUtil.DEV_NULL");
7 | public class DerbyUtil {
8 | public static final OutputStream DEV_NULL = new OutputStream() {
9 | public void write(int b) {}
10 | };
11 | }
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/rdf_processing_toolkit/cli/cmd/RptCmdUtils.java:
--------------------------------------------------------------------------------
1 | package org.aksw.rdf_processing_toolkit.cli.cmd;
2 |
3 | import org.aksw.commons.picocli.CmdUtils;
4 |
5 | /**
6 | * Wrapper for {@link CmdUtils} that initializes global settings.
7 | */
8 | public class RptCmdUtils {
9 | static { CliUtils.configureGlobalSettings(); }
10 |
11 | public static void execCmd(Class> cmdClass, String[] args) {
12 | CmdUtils.execCmd(cmdClass, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/gtree.rq:
--------------------------------------------------------------------------------
1 | # This query is similar to tree.rq with the difference that it operates on every named graph.
2 |
3 | PREFIX norse:
4 |
5 | CONSTRUCT {
6 | GRAPH ?g { ?s ?p ?o }
7 | }
8 | WHERE {
9 | GRAPH ?g { ?sub ?p ?obj }
10 | BIND(IF(EXISTS { GRAPH ?g { [] ?p1 ?sub . ?sub ?p2 [] } }, norse:bnode.asGiven(?sub), ?sub) AS ?s)
11 | BIND(IF(EXISTS { GRAPH ?g { [] ?p1 ?obj . ?obj ?p2 [] } }, norse:bnode.asGiven(?obj), ?obj) AS ?o)
12 | }
13 |
--------------------------------------------------------------------------------
/ngs/ngs-benchmark.sh:
--------------------------------------------------------------------------------
1 | #zsh time output looks better imo
2 | #/bin/bash
3 |
4 | data="$1"
5 | query="$2"
6 |
7 | time ngs map --sparql "$query" "$data" > /tmp/ngs-bench-map.trig
8 |
9 | # Note: --u for union default graph mode not needed as the query is graph aware
10 | # Note --w=trig/pretty is too slow - see https://issues.apache.org/jira/browse/JENA-1848
11 | # time sparql-integrate --w=trig/pretty test-data.trig even.sparql > /tmp/ngs-bench-si.trig
12 | time sparql-integrate "$data" "$query" > /tmp/ngs-bench-si.trig
13 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/test/resources/fix-geom.sparql:
--------------------------------------------------------------------------------
1 | SELECT * {
2 | BIND("POLYGON((11.118292808532715 46.069896058164055, 11.118561029434204 46.069352683251914))" AS ?x)
3 |
4 | # BIND(REPLACE(?x, ".*\\(\\(([^,]*),.*", "$1") AS ?part)
5 | # BIND(REPLACE(?x, "(\\)\\))", CONCAT(', ', ?part, "$1")) AS ?final)
6 |
7 |
8 |
9 |
10 | BIND(
11 | STRDT(REPLACE(STR(?x), "(\\)\\))", CONCAT(', ', REPLACE(STR(?x), ".*\\(\\(([^,]*),.*", "$1"), "$1")), geo:wktLiteral)
12 | AS ?oneLiner)
13 |
14 |
15 |
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_integrate/cli/cmd/ConverterDuration.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_integrate.cli.cmd;
2 |
3 | import java.time.Duration;
4 |
5 | import org.aksw.commons.util.time.TimeAgo;
6 |
7 | import picocli.CommandLine.ITypeConverter;
8 |
9 | public class ConverterDuration implements ITypeConverter {
10 | @Override
11 | public Duration convert(String value) throws Exception {
12 | Duration result = TimeAgo.parse(value);
13 | return result;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/unsorted-tests/iotest.nt:
--------------------------------------------------------------------------------
1 | "4"^^ .
2 | "3"^^ .
3 | "2"^^ .
4 | "1"^^ .
5 | "0"^^ .
6 |
--------------------------------------------------------------------------------
/docs/examples/macros.ttl:
--------------------------------------------------------------------------------
1 | PREFIX udf:
2 |
3 | # Reuse of shacl's prefix vocabulary
4 | PREFIX sh:
5 | PREFIX eg:
6 |
7 | eg:prefixMapping
8 | # sh:declare [ sh:prefix "fn" ; sh:namespace fn: ] # apparently strict shacl does not allow for the shorthand
9 | sh:declare [ sh:prefix "afn" ; sh:namespace "http://jena.apache.org/ARQ/function#" ]
10 | .
11 |
12 | # SELECT (eg:greet('John Doe') AS ?x) {}
13 | eg:greet udf:simpleDefinition ("CONCAT('Hello ', STR(?x), '!')" "x") .
14 |
15 |
--------------------------------------------------------------------------------
/sportal/sportal-qf10.sparql:
--------------------------------------------------------------------------------
1 | PREFIX v:
2 | PREFIX s:
3 |
4 | CONSTRUCT {
5 |
6 | v:propertyPartition [
7 | v:property ?p ;
8 | s:objectTypes [
9 | s:objectClass ?oType ;
10 | s:distinctMembers ?x
11 | ]
12 | ]
13 | }
14 | WHERE {
15 | { SELECT (COUNT(?o) AS ?x) ?p ?oType WHERE {
16 | SERVICE {
17 | ?s ?p ?o . ?o a ?oType .
18 | }
19 | } GROUP BY ?p ?oType }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_binding_stream/cli/main/MainCliSparqlBindingStream.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_binding_stream.cli.main;
2 |
3 | import org.aksw.rdf_processing_toolkit.cli.cmd.CliUtils;
4 | import org.aksw.rdf_processing_toolkit.cli.cmd.RptCmdUtils;
5 | import org.aksw.sparql_binding_stream.cli.cmd.CmdSbsMain;
6 |
7 | public class MainCliSparqlBindingStream {
8 | static { CliUtils.configureGlobalSettings(); }
9 |
10 | public static void main(String[] args) {
11 | RptCmdUtils.execCmd(CmdSbsMain.class, args);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_integrate/cli/main/MainCliSparqlIntegrate.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_integrate.cli.main;
2 |
3 | import org.aksw.rdf_processing_toolkit.cli.cmd.CliUtils;
4 | import org.aksw.rdf_processing_toolkit.cli.cmd.RptCmdUtils;
5 | import org.aksw.sparql_integrate.cli.cmd.CmdSparqlIntegrateMain;
6 |
7 | public class MainCliSparqlIntegrate {
8 | static { CliUtils.configureGlobalSettings(); }
9 |
10 | public static void main(String[] args) {
11 | RptCmdUtils.execCmd(CmdSparqlIntegrateMain.class, args);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qdAll.rq:
--------------------------------------------------------------------------------
1 | PREFIX v:
2 |
3 | CONSTRUCT {
4 |
5 | v:propertyPartition ?l .
6 |
7 | ?l
8 | v:property ?p ;
9 | v:triples ?x ;
10 | v:distinctSubjects ?a ;
11 | v:distinctObjects ?c
12 | }
13 | {
14 | {
15 | SELECT ?p
16 | (IRI(CONCAT(STR(), '/pp/', ENCODE_FOR_URI(STR(?p)))) AS ?l)
17 | (COUNT(?o) AS ?x)
18 | (COUNT(DISTINCT ?s) AS ?a)
19 | (COUNT(DISTINCT ?o) AS ?c)
20 | {
21 | ?s ?p ?o
22 | }
23 | GROUP BY ?p
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-pkg-parent/rdf-processing-toolkit-pkg-deb-cli/src/deb/resources/usr/bin/voidgen:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #WORK_DIR=`dirname "$0"`
4 |
5 | LIB_DIR="/usr/share/rdf-processing-toolkit-cli/"
6 | MAIN_CLASS="org.aksw.data_profiler.cli.MainCliVoidGenerator"
7 |
8 | #java -cp "$LIB_DIR:$LIB_DIR/lib/*" "-Dloader.main=${MAIN_CLASS}" "org.springframework.boot.loader.PropertiesLauncher" "$@"
9 |
10 | EXTRA_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED"
11 | java $EXTRA_OPTS $JAVA_OPTS -cp "$LIB_DIR:$LIB_DIR/lib/*" "$MAIN_CLASS" "$@"
12 |
13 |
--------------------------------------------------------------------------------
/docs/demos/leaflet-graphql/query-countries.rq:
--------------------------------------------------------------------------------
1 | PREFIX geo:
2 | PREFIX coy:
3 |
4 | CONSTRUCT {
5 | ?x ?y ?z
6 | }
7 | {
8 | GRAPH {
9 | ?s a coy:Country .
10 | }
11 | LATERAL {
12 | { GRAPH {
13 | ?s (!geo:hasGeometry)* ?x .
14 | ?x ?y ?z
15 | } }
16 | UNION
17 | { GRAPH {
18 | ?s (|!
)* ?x .
19 | ?x ?y ?z
20 | } }
21 | }
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qcAllBut35.rq:
--------------------------------------------------------------------------------
1 | PREFIX v:
2 |
3 | CONSTRUCT {
4 |
5 | v:classPartition ?k .
6 |
7 | ?k
8 | v:class ?t ;
9 | v:triples ?x ;
10 | v:properties ?b ;
11 | v:distinctObjects ?c
12 | }
13 | {
14 | {
15 | SELECT
16 | (IRI(CONCAT(STR(), '/cp/', ENCODE_FOR_URI(STR(?t)))) AS ?k)
17 | (COUNT(?s) AS ?x)
18 | (COUNT(DISTINCT ?p) AS ?b)
19 | (COUNT(DISTINCT ?o) AS ?c)
20 | {
21 | ?s
22 | a ?t ;
23 | ?p ?o
24 | }
25 | GROUP BY ?t
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/docs/sparql-extensions/function-extensions.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Function Extensions
3 | parent: SPARQL Extensions
4 | nav_order: 20
5 | layout: default
6 | ---
7 |
8 | # SPARQL Function Extensions
9 |
10 | * Most functions are explained in the [Examples Section](https://github.com/SmartDataAnalytics/RdfProcessingToolkit/tree/develop/docs/examples).
11 |
12 | * A further function reference is available at [http://jsa.aksw.org/fn/](http://jsa.aksw.org/fn/).
13 | Note, that the functions are being consolidated into the new `norse` (Not Only Rdf Sparql Extensions) namespace `norse: `.
14 |
15 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-pkg-parent/rdf-processing-toolkit-pkg-deb-cli/src/deb/resources/usr/bin/sparql-load:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #WORK_DIR=`dirname "$0"`
4 |
5 | LIB_DIR="/usr/share/rdf-processing-toolkit-cli/"
6 | MAIN_CLASS="org.aksw.rdf_processing_toolkit.cli.MainCliSparqlLoad"
7 |
8 | #java -cp "$LIB_DIR:$LIB_DIR/lib/*" "-Dloader.main=${MAIN_CLASS}" "org.springframework.boot.loader.PropertiesLauncher" "$@"
9 |
10 | EXTRA_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED"
11 | java $EXTRA_OPTS $JAVA_OPTS -cp "$LIB_DIR:$LIB_DIR/lib/*" "${MAIN_CLASS}" "$@"
12 |
13 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-pkg-parent/rdf-processing-toolkit-pkg-deb-cli/src/deb/control/control:
--------------------------------------------------------------------------------
1 | Package: rdf-processing-toolkit-cli
2 | Version: [[version]]
3 | Section: web
4 | Priority: optional
5 | Architecture: all
6 | Depends: java-runtime-headless
7 | Maintainer: Claus Stadler
8 | Description: RDF Processing Toolkit Command Line Interfaces
9 | Distribution: ldstack-nightly
10 | Homepage: http://aksw.org/Projects/RdfProcessingToolkit
11 | Vcs-Git: git://github.com/SmartDataAnalytics/RdfProcessingToolkit.git
12 | Vcs-Browser: https://github.com/SmartDataAnalytics/RdfProcessingToolkit
13 |
--------------------------------------------------------------------------------
/docs/examples/json-zip-arrays.sparql:
--------------------------------------------------------------------------------
1 | # Insert an example resource with a JSON literal
2 | INSERT DATA {
3 | eg:workload1 eg:workload """{
4 | "ids": [ "id1", "id2"],
5 | "names": [ "name1", "name2", ]
6 | }"""^^xsd:json
7 | }
8 |
9 |
10 | # Combine id and name
11 | SELECT ?s ?name
12 | WHERE {
13 | ?x eg:workload ?o .
14 | BIND(json:path(?o, "$.ids") AS ?ids)
15 | BIND(json:path(?o, "$.names") AS ?names)
16 |
17 | ?ids json:unnest (?id ?i) .
18 | ?names json:unnest (?name ?i) .
19 |
20 | BIND("http://www.example.org/" AS ?ns)
21 | BIND(IRI(CONCAT(?ns, ENCODE_FOR_URI(?id))) AS ?s)
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/sportal/sportal-qe2.sparql:
--------------------------------------------------------------------------------
1 | PREFIX v:
2 |
3 | CONSTRUCT {
4 | #
5 |
6 | v:classPartition [
7 | v:class ?c ;
8 | v:propertyPartition [
9 | v:property ?p ;
10 | v:triples ?x
11 | ]
12 | ]
13 | }
14 | WHERE {
15 | { SELECT (COUNT(?o) AS ?x) ?p {
16 | # SERVICE {
17 | SERVICE {
18 | # SERVICE {
19 | # ?s ?p ?o ; a ?c
20 | ?s a ?c ; ?p ?o
21 | }
22 | } GROUP BY ?c ?p }
23 | }
24 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_binding_stream/cli/cmd/CmdSbsMain.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_binding_stream.cli.cmd;
2 |
3 | import org.aksw.rdf_processing_toolkit.cli.cmd.CmdCommonBase;
4 | import org.aksw.rdf_processing_toolkit.cli.cmd.VersionProviderRdfProcessingToolkit;
5 |
6 | import picocli.CommandLine.Command;
7 |
8 | @Command(name="sbs",
9 | versionProvider = VersionProviderRdfProcessingToolkit.class,
10 | description = "SPARQL Binding Streams Subcommands", subcommands = {
11 | CmdSbsMap.class,
12 | CmdSbsFilter.class,
13 | CmdSbsSplit.class
14 | })
15 | public class CmdSbsMain
16 | extends CmdCommonBase
17 | {
18 | }
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/rdf_processing_toolkit/cli/cmd/CmdCommonBase.java:
--------------------------------------------------------------------------------
1 | package org.aksw.rdf_processing_toolkit.cli.cmd;
2 |
3 | import picocli.CommandLine.Option;
4 |
5 | public class CmdCommonBase
6 | implements HasDebugMode
7 | {
8 | @Option(names = { "-X" }, description = "Debug output such as full stacktraces")
9 | public boolean debugMode = false;
10 |
11 | @Option(names = { "-h", "--help" }, usageHelp = true)
12 | public boolean help = false;
13 |
14 | @Option(names = { "-v", "--version" }, versionHelp = true)
15 | public boolean version = false;
16 |
17 | @Override
18 | public boolean isDebugMode() {
19 | return debugMode;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/tree.rq:
--------------------------------------------------------------------------------
1 | # This query turns every intermediate RDF node into a blank node.
2 | # An intermediate node is any RDF term that appears both as a subject and an object.
3 | # Formatting the resulting RDF graph with jena's 'turtle/pretty' format outputs nicely formatted trees.
4 | # Example usage: rpt integrate --out-format turtle/pretty data.nt tree.rq
5 |
6 | PREFIX norse:
7 |
8 | CONSTRUCT {
9 | ?s ?p ?o
10 | }
11 | WHERE {
12 | ?sub ?p ?obj
13 | BIND(IF(EXISTS { [] ?p1 ?sub . ?sub ?p2 [] }, norse:bnode.asGiven(?sub), ?sub) AS ?s)
14 | BIND(IF(EXISTS { [] ?p1 ?obj . ?obj ?p2 [] }, norse:bnode.asGiven(?obj), ?obj) AS ?o)
15 | }
16 |
--------------------------------------------------------------------------------
/docs/examples/test-zip-arrays.sparql:
--------------------------------------------------------------------------------
1 | INSERT DATA {
2 | eg:workload1 eg:workload """{
3 | "stopIds": [ "TRENTO_STATION_FTM", "TRENTO_NORD"],
4 | "stopNames": [ "Trento Staz.Ftm", "Trento Nord", ]
5 | }"""^^xsd:json
6 | }
7 |
8 | # Add stop labels
9 | #CONSTRUCT { GRAPH ?x { ?s a eg:TrainStop ; rdfs:label ?l } }
10 | SELECT ?s ?l
11 | WHERE {
12 | ?x eg:workload ?o .
13 | BIND(json:path(?o, "$.stopIds") AS ?stops)
14 | BIND(json:path(?o, "$.stopNames") AS ?stopNames)
15 |
16 | ?stops json:unnest (?stop ?i) .
17 | ?stopNames json:unnest (?l ?i) .
18 |
19 | BIND("http://qrowd-project.eu/resource/" AS ?ns)
20 | BIND(URI(CONCAT(?ns, 'stop-', ENCODE_FOR_URI(?stop))) AS ?s)
21 | }
22 |
23 |
24 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/rdf_processing_toolkit/cli/cmd/VersionProviderRdfProcessingToolkit.java:
--------------------------------------------------------------------------------
1 | package org.aksw.rdf_processing_toolkit.cli.cmd;
2 |
3 | import java.util.Arrays;
4 | import java.util.Collection;
5 | import java.util.Properties;
6 |
7 | public class VersionProviderRdfProcessingToolkit
8 | extends VersionProviderFromClasspathProperties
9 | {
10 | @Override public String getResourceName() { return "rdf-processing-toolkit.properties"; }
11 | @Override public Collection getStrings(Properties p) { return Arrays.asList(
12 | p.get("rdf-processing-toolkit.version") + " built at " + p.get("rdf-processing-toolkit.build.timestamp")
13 | ); }
14 | }
15 |
--------------------------------------------------------------------------------
/docs/sparql-extensions/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: SPARQL Extensions
3 | nav_order: 40
4 | has_children: true
5 | layout: default
6 | ---
7 |
8 | # SPARQL Extensions
9 | RPT's SPARQL extensions are provided by our unofficial Jena eXtensions project called [JenaX](https://scaseco.github.io/jenax/).
10 |
11 | * The section [RDF/SPARQL Processing - Examples](../examples) demonstrates both the usage of the `integrate` command as well as various SPARQL extenions.
12 | * The extensions can be used standalone, such as with Jena Java projects, or as plugins for a Fuseki server. For more information, see the [JenaX ARQ Plugins documentation](https://scaseco.github.io/jenax/jenax-arq-parent/jenax-arq-plugins-parent/README.html).
13 |
14 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qf9.rq:
--------------------------------------------------------------------------------
1 | PREFIX v:
2 | PREFIX s:
3 |
4 | CONSTRUCT {
5 |
6 | v:propertyPartition ?l .
7 |
8 | ?l
9 | v:property ?p ;
10 | s:subjectTypes ?k .
11 |
12 | ?k
13 | s:subjectClass ?t ;
14 | s:distinctMembers ?x
15 | }
16 | {
17 | SELECT
18 | (CONCAT(STR(), '/pp/', ENCODE_FOR_URI(STR(?p))) AS ?lStr)
19 | (IRI(?lStr) AS ?l)
20 | (IRI(CONCAT(?lStr, '/cp/', ENCODE_FOR_URI(STR(?t)), '/st')) AS ?k)
21 | ?p ?t ?x
22 | {
23 | SELECT ?p ?t (COUNT(?o) AS ?x)
24 | {
25 | ?s
26 | a ?t ;
27 | ?p ?o
28 | }
29 | GROUP BY ?p ?t
30 | }
31 | }
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_integrate/cli/main/MainPlaygroundDataset.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_integrate.cli.main;
2 |
3 | import org.apache.jena.query.Dataset;
4 | import org.apache.jena.query.DatasetFactory;
5 | import org.apache.jena.rdfconnection.RDFConnection;
6 | import org.apache.jena.sparql.exec.QueryExecBuilderAdapter;
7 | import org.apache.jena.sparql.util.Context;
8 |
9 | public class MainPlaygroundDataset {
10 | public static void main(String[] args) {
11 | Dataset ds = DatasetFactory.create();
12 | try (RDFConnection conn = RDFConnection.connect(ds)) {
13 | Context cxt;
14 | cxt = QueryExecBuilderAdapter.adapt(conn.newQuery()).getContext();
15 | System.out.println(cxt);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_integrate/cli/CommandMain.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_integrate.cli;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import com.beust.jcommander.Parameter;
7 | import com.beust.jcommander.Parameters;
8 |
9 | @Parameters(separators = "=", commandDescription = "Show SPARQL Stream information")
10 | public class CommandMain {
11 | @Parameter(description="Non option args")
12 | public List nonOptionArgs = new ArrayList<>();
13 |
14 | @Parameter(names="-f", description="Preferred RDF format")
15 | public String preferredRdfFormat;
16 |
17 | @Parameter(names={"-h", "--help"}, help = true)
18 | public boolean help = false;
19 |
20 | @Parameter(names="-u")
21 | public boolean isUnionDefaultGraphMode = false;
22 | }
23 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qf10.rq:
--------------------------------------------------------------------------------
1 | PREFIX v:
2 | PREFIX s:
3 |
4 | CONSTRUCT {
5 |
6 | v:propertyPartition ?l .
7 |
8 | ?l
9 | v:property ?p ;
10 | s:objectTypes ?k .
11 |
12 | ?k
13 | s:objectClass ?t ;
14 | s:distinctMembers ?x
15 | }
16 | {
17 | SELECT
18 | (CONCAT(STR(), '/pp/', ENCODE_FOR_URI(STR(?p))) AS ?lStr)
19 | (IRI(?lStr) AS ?l)
20 | (IRI(CONCAT(?lStr, '/cp/', ENCODE_FOR_URI(STR(?t)), '/ot')) AS ?k)
21 | # (IRI(CONCAT('x-ppcp://', ENCODE_FOR_URI(STR(?p)), '-', ENCODE_FOR_URI(STR(?t)))) AS ?k)
22 | ?p ?t ?x
23 | {
24 | SELECT ?p ?t (COUNT(?o) AS ?x)
25 | {
26 | ?s ?p ?o .
27 | ?o a ?t
28 | }
29 | GROUP BY ?p ?t
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - "develop"
7 | pull_request:
8 |
9 | jobs:
10 | # Build job
11 | build:
12 | runs-on: ubuntu-latest
13 | steps:
14 | - name: Checkout
15 | uses: actions/checkout@v3
16 | - name: Setup Ruby
17 | uses: ruby/setup-ruby@v1
18 | with:
19 | ruby-version: '3.1' # Not needed with a .ruby-version file
20 | bundler-cache: true # runs 'bundle install' and caches installed gems automatically
21 | cache-version: 0 # Increment this number if you need to re-download cached gems
22 | working-directory: '${{ github.workspace }}/docs'
23 | - name: Build with Jekyll
24 | run: bundle exec jekyll build
25 | working-directory: '${{ github.workspace }}/docs'
26 |
27 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/main/DatasetFlowOps.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.main;
2 |
3 | public class DatasetFlowOps {
4 |
5 | /**
6 | * Apply a mapper based on RDFConnection on Datasets
7 | *
8 | * @param mapper
9 | * @return
10 | */
11 | // public static FlowableTransformer datasetToConnection(Function> mapper) {
12 | // return upstream -> {
13 | // return upstream.flatMap(ds -> {
14 | // return Flowable.using(
15 | // () -> RDFConnectionFactory.connect(ds),
16 | // mapper::apply,
17 | // RDFConnection::close);
18 | // });
19 | // };
20 | // }
21 |
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/compact/qeAll.rq:
--------------------------------------------------------------------------------
1 | PREFIX v:
2 |
3 | CONSTRUCT {
4 |
5 | v:classPartition ?k .
6 |
7 | ?k
8 | v:class ?t ;
9 | v:propertyPartition ?l .
10 |
11 | ?l
12 | v:property ?p ;
13 | v:triples ?x ;
14 | v:distinctSubjects ?a ;
15 | v:distinctObjects ?c
16 | }
17 | {
18 | SELECT
19 | (CONCAT(STR(), '/cp/', ENCODE_FOR_URI(STR(?t))) AS ?kStr)
20 | (IRI(?kStr) AS ?k)
21 | (IRI(CONCAT(?kStr, '/pp/', ENCODE_FOR_URI(STR(?p)))) AS ?l)
22 | ?t ?p ?x ?a ?b ?c
23 | {
24 | SELECT
25 | ?t
26 | ?p
27 | (COUNT(?s) AS ?x)
28 | (COUNT(DISTINCT ?s) AS ?a)
29 | (COUNT(DISTINCT ?o) AS ?c)
30 | {
31 | ?s
32 | a ?t ;
33 | ?p ?o
34 | }
35 | GROUP BY ?t ?p
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/docs/publications/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Publications
3 | has_children: false
4 | nav_order: 200
5 | layout: default
6 | ---
7 |
8 |
9 |
10 | The following components of RPT have been published:
11 |
12 |
13 | * **Scaling RML and SPARQL-based Knowledge Graph Construction with Apache Spark.**
14 |
15 | *Stadler, Claus and B{\"u}hmann, Lorenz and Meyer, Lars-Peter and Martin, Michael*
16 |
17 | KGCW2023, the 4th International Workshop on Knowledge Graph Construction @ ESWC2023
18 |
19 | ```bibtex
20 | @inproceedings{kgcw2023sbmm,
21 | title={Scaling RML and SPARQL-based Knowledge Graph Construction with Apache Spark},
22 | author={Stadler, Claus and B{\"u}hmann, Lorenz and Meyer, Lars-Peter and Martin, Michael},
23 | booktitle={KGCW2023, the 4th International Workshop on Knowledge Graph Construction},
24 | year={2023}
25 | }
26 | ```
27 |
28 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/rdf_processing_toolkit/cli/main/MainCliRdfProcessingToolkit.java:
--------------------------------------------------------------------------------
1 | package org.aksw.rdf_processing_toolkit.cli.main;
2 |
3 | import org.aksw.commons.picocli.CmdUtils;
4 | import org.aksw.rdf_processing_toolkit.cli.cmd.CliUtils;
5 | import org.aksw.rdf_processing_toolkit.cli.cmd.CmdRptMain;
6 |
7 | import picocli.CommandLine;
8 |
9 | public class MainCliRdfProcessingToolkit {
10 | static { CliUtils.configureGlobalSettings(); }
11 |
12 | public static void main(String[] args) throws Exception {
13 | // CmdUtils.execCmd(CmdRptMain.class, args);
14 | CommandLine commandLine = new CommandLine(new CmdRptMain());
15 |
16 | // Register sansa dynamically
17 | CmdUtils.registerIfAvailable(commandLine, "net.sansa_stack.spark.cli.cmd.CmdSansaParent");
18 |
19 | CmdUtils.execCmd(commandLine, args);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/NOTES.md:
--------------------------------------------------------------------------------
1 | TODO Outdated values; We reported https://issues.apache.org/jira/browse/JENA-1862 and need to redo the eval...
2 |
3 |
4 | ### Performance Metrics
5 |
6 | The `ngs` folder contains a small benchmark utility:
7 |
8 | ```
9 | # Create a given number of graphs
10 | ./ngs-create-test-data.sh 1000000 > test-data.trig
11 |
12 | # The benchmark task is to emit all named graphs containing an even number
13 | ./ngs-benchmark.sh
14 | ```
15 |
16 |
17 | * Running a single query over the whole dataset vs parallel map
18 |
19 | Notebook, 2 cores + ht
20 |
21 | even.sparql
22 |
23 | ngs-map 165.54user 6.56system 0:53.02elapsed 324%CPU
24 | sparql-integrate 139.77user 1.82system 0:51.12elapsed 276%CPU
25 |
26 |
27 |
28 | hash.sparql
29 |
30 | ngs-map 182.86user 7.20system 0:57.41elapsed 331%CPU
31 | sparql-integrate 155.86user 2.03system 0:58.42elapsed 270%CPU
32 |
33 |
34 |
35 | Server:
36 |
37 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_integrate/cli/cmd/CmdRptServe.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_integrate.cli.cmd;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.stream.Stream;
6 |
7 | import org.aksw.rdf_processing_toolkit.cli.cmd.CmdRptMain;
8 |
9 | import picocli.CommandLine;
10 | import picocli.CommandLine.Command;
11 | import picocli.CommandLine.ParentCommand;
12 | import picocli.CommandLine.Unmatched;
13 |
14 | @Command(name = "serve", description = "Alias for `integrate --server`")
15 | public class CmdRptServe implements Runnable {
16 | @ParentCommand CmdRptMain parent;
17 |
18 | @Unmatched
19 | public List args = new ArrayList<>();
20 |
21 | @Override
22 | public void run() {
23 | new CommandLine(new CmdSparqlIntegrateMain())
24 | .execute(Stream.concat(Stream.of("--server"), args.stream()).toArray(String[]::new));
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/test/java/org/aksw/sparql_integrate/ngs/cli/main/TestCliNgs.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_integrate.ngs.cli.main;
2 |
3 | import org.junit.Test;
4 |
5 | public class TestCliNgs {
6 |
7 | @Test
8 | public void test() {
9 | // MainCliNamedGraphStream.mainCore(new String[] {"tail", "-n", "+1", "ngs-nato-phonetic-alphabet.trig"});
10 | // MainCliNamedGraphStream.mainCore(new String[] {"map", "--sparql", "* { ?s foaf:name ?o }", "ngs-nato-phonetic-alphabet.trig"});
11 | // MainCliNamedGraphStream.mainCore(new String[] {"map", "--sparql", "CONSTRUCT WHERE { ?s foaf:name ?o }", "ngs-nato-phonetic-alphabet.trig"});
12 | // MainCliNamedGraphStream.mainCore(new String[] {"git", "/home/raven/Projects/Eclipse/lodservatory/latest-status.ttl"});
13 | // MainCliNamedGraphStream.mainCore(new String[] {"map", "-s", "* { GRAPH ?g { ?s ?p ?o } }", "/home/raven/tmp/sorttest/subjects.trig"});
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgsMain.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import org.aksw.rdf_processing_toolkit.cli.cmd.CmdCommonBase;
4 | import org.aksw.rdf_processing_toolkit.cli.cmd.VersionProviderRdfProcessingToolkit;
5 |
6 | import picocli.CommandLine.Command;
7 |
8 | @Command(name="ngs",
9 | versionProvider = VersionProviderRdfProcessingToolkit.class,
10 | description = "Named Graph Stream Subcommands",
11 | subcommands = {
12 | CmdNgsCat.class,
13 | CmdNgsFilter.class,
14 | CmdNgsHead.class,
15 | CmdNgsTail.class,
16 | CmdNgsMap.class,
17 | // CmdNgsMerge.class,
18 | CmdNgsProbe.class,
19 | CmdNgsSort.class,
20 | CmdNgsSubjects.class,
21 | CmdNgsUntil.class,
22 | CmdNgsWc.class,
23 | CmdNgsWhile.class,
24 | CmdNgsGit.class
25 | })
26 | public class CmdNgsMain
27 | extends CmdCommonBase
28 | {
29 | }
30 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgsCat.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.concurrent.Callable;
6 |
7 | import org.aksw.named_graph_stream.cli.main.NgsCmdImpls;
8 |
9 | import picocli.CommandLine.Command;
10 | import picocli.CommandLine.Option;
11 | import picocli.CommandLine.Parameters;
12 |
13 | @Command(name = "cat", description = "Output and optionally convert graph input")
14 | public class CmdNgsCat implements Callable {
15 |
16 | @Option(names = { "-h", "--help" }, usageHelp = true)
17 | public boolean help = false;
18 |
19 | @Option(names = { "-o", "--out-format" })
20 | public String outFormat = "trig/blocks";
21 |
22 | @Parameters(arity = "0..*", description = "Input files")
23 | public List nonOptionArgs = new ArrayList<>();
24 |
25 | @Override
26 | public Integer call() throws Exception {
27 | return NgsCmdImpls.cat(this);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/bitmask.sparql:
--------------------------------------------------------------------------------
1 | # Exploit named graphs to model associative arrays (i.e. Maps) in RDF
2 | INSERT DATA {
3 | GRAPH eg:modeOfTransportation {
4 | eg:Bike eg:hasBit 1 .
5 | eg:Car eg:hasBit 2 .
6 | eg:Train eg:hasBit 4 .
7 | eg:Airplane eg:hasBit 8 .
8 | }
9 | }
10 |
11 | CONSTRUCT {
12 | eg:s eg:usesMode ?o
13 | } WHERE {
14 | BIND(10 AS ?bitmask)
15 |
16 | # Convert the integer to
17 | # (1) a binary string representation, (2) split the string by each character into a JSON array
18 | # (3) reverse the order
19 | BIND(json:reverse(json:split(json:binaryString(?bitmask), "(?!$)")) AS ?bitarr)
20 |
21 | # Unnest each charactor ("0" or "1") with its array index
22 | ?bitarr json:unnest (?bitstr ?bitindex)
23 |
24 | # Filter out zero bits
25 | FILTER(?bitstr != "0")
26 |
27 | # Obtain the bit's corresponding decimal value (using Jena's power function)
28 | BIND(math:pow(2, ?bitindex) AS ?val)
29 |
30 | # Perform the lookup
31 | OPTIONAL { GRAPH eg:modeOfTransportation { ?o eg:hasBit ?val } }
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/docs/graphql/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: GraphQL over SPARQL
3 | has_children: true
4 | nav_order: 100
5 | layout: default
6 | ---
7 |
8 | # GraphQL over SPARQL
9 |
10 | This section describes out approach to generate JSON responses from SPARQL endpoints using GraphQL as a query and mapping language.
11 | Mutations are not supported.
12 | The GraphQL queries of our approach are self-contained, i.e. no additional server configuration is needed. The endpoint is avilable when running [`rpt integrate --server`](../integrate), by default [http://localhost:8642/graphql](http://localhost:8642/graphql).
13 | From each GraphQL query a corresponding SPARQL query and result set post processor is created.
14 |
15 | ## Examples
16 |
17 | Check out the [online demonstrators](demo) for examples.
18 |
19 | ## Directives
20 |
21 | The following is the set of supported directives:
22 |
23 | [`@prefix`](reference/prefix) [`@pattern`](reference/pattern) [`@bind`](reference/bind) [`@one` and `@many`](reference/one-and-many) [`@index`](reference/index-directive) [`@join`](reference/join)
24 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/shacl-targetClass.rq:
--------------------------------------------------------------------------------
1 | PREFIX sh:
2 |
3 | PREFIX ns:
4 |
5 | CONSTRUCT {
6 | ?shape
7 | a sh:NodeShape ;
8 | rdfs:label ?label ;
9 | sh:targetClass ?class
10 | .
11 |
12 | ?shape sh:property ?shp .
13 | ?shp sh:path ?p .
14 | }
15 | {
16 | SELECT * {
17 | { SELECT DISTINCT ?class {
18 | [] a ?class
19 | } }
20 | LATERAL {
21 | SELECT DISTINCT ?p {
22 | [] a ?class ; ?p []
23 | }
24 | }
25 |
26 | BIND(STR(ns:) AS ?nsStr)
27 | BIND(STR(?class) AS ?classStr)
28 | BIND(ENCODE_FOR_URI(?classStr) AS ?classStrEnc)
29 |
30 | BIND(STR(?p) AS ?pStr)
31 | BIND(ENCODE_FOR_URI(?pStr) AS ?pStrEnc)
32 |
33 | BIND(CONCAT(?nsStr, 'shape/', ?classStrEnc) AS ?shapeStr)
34 | BIND(IRI(?shapeStr) AS ?shape)
35 | BIND(CONCAT("Shape for ", ?classStr) AS ?label)
36 | # BIND(IRI(CONCAT(?shapeStr, '/', ENCODE_FOR_URI(STR(?p)))) AS ?shp)
37 | BIND(BNODE() AS ?shp)
38 | }
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/rdf_processing_toolkit/cli/cmd/CmdMixinSparqlDataset.java:
--------------------------------------------------------------------------------
1 | package org.aksw.rdf_processing_toolkit.cli.cmd;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import org.apache.jena.sparql.core.DatasetDescription;
8 |
9 | import picocli.CommandLine.Option;
10 |
11 | public class CmdMixinSparqlDataset
12 | implements Serializable
13 | {
14 | private static final long serialVersionUID = 1L;
15 |
16 | @Option(names = { "--dg", "--default-graph" }, description="Default graph")
17 | public List defaultGraphs = new ArrayList<>();
18 |
19 | @Option(names = { "--ng", "--named-graph" }, description="Named graph")
20 | public List namedGraphs = new ArrayList<>();
21 |
22 | @Option(names = { "--service" }, description = "SPARQL endpoint URL")
23 | public boolean serviceUrl;
24 |
25 | public static DatasetDescription toDatasetDescription(CmdMixinSparqlDataset cmd) {
26 | return new DatasetDescription(cmd.defaultGraphs, cmd.namedGraphs);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/jena_sparql_api/rx/op/api/OpConfigSort.java:
--------------------------------------------------------------------------------
1 | package org.aksw.jena_sparql_api.rx.op.api;
2 |
3 | import java.nio.file.Path;
4 | import java.util.function.Function;
5 |
6 | import org.aksw.jenax.arq.dataset.api.ResourceInDataset;
7 |
8 | import io.reactivex.rxjava3.core.FlowableTransformer;
9 |
10 | /**
11 | * Interface for common parameters of sort operations
12 | *
13 | * @author raven
14 | *
15 | */
16 | public interface OpConfigSort {
17 | OpConfigSort setTemporaryDirectory(Path path);
18 | Path getTemporaryDirectory();
19 |
20 | Function super T, K> getKeyFn();
21 | OpConfigSort setKeyFn(Function keyFn);
22 |
23 | OpConfigSort setRandomSort(boolean onOrOff);
24 | OpConfigSort setReverse(boolean onOrOff);
25 | OpConfigSort setUnique(boolean onOrOff);
26 |
27 | OpConfigSort setBufferSize(long sizeInBytes);
28 | OpConfigSort setParallel(int parallel);
29 |
30 | OpConfigSort mergeConsecutiveRecords(boolean onOrOff);
31 |
32 | FlowableTransformer get();
33 | }
34 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/log4j2.yaml.template.bak:
--------------------------------------------------------------------------------
1 | # YAML requires additional dependencies to work; i guess its easier to use slightly more verbose properties files
2 | # rather than fiddling with jackson databinding...
3 | Configuration:
4 | name: RptLoggerConfig
5 | status: debug
6 | appenders:
7 | Console:
8 | name: STDERR
9 | target: SYSTEM_ERR
10 | PatternLayout:
11 | Pattern: "[%p] %m%n"
12 |
13 | Loggers:
14 | Root:
15 | level: debug
16 | AppenderRef:
17 | ref: STDERR
18 | logger:
19 | -
20 | name: org.eclipse.jetty
21 | level: warn
22 | -
23 | name: org.springframework
24 | level: warn
25 | -
26 | name: org.aksw.jena_sparql_api.web.filters.CorsFilter
27 | level: warn
28 | -
29 | name: org.apache.jena.riot.resultset.rw
30 | level: off
31 | -
32 | name: org.apache.jena.sparql.syntax.syntaxtransform.ElementTransformer
33 | level: off
34 | -
35 | name: org.aksw.jena_sparql_api.sparql.ext.fs.QueryIterServiceOrFile
36 | level: info
37 |
38 |
39 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/IParameterConsumerFlaggedLong.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import java.util.AbstractMap.SimpleEntry;
4 | import java.util.Stack;
5 |
6 | import picocli.CommandLine.IParameterConsumer;
7 | import picocli.CommandLine.Model.ArgSpec;
8 | import picocli.CommandLine.Model.CommandSpec;
9 |
10 | public abstract class IParameterConsumerFlaggedLong implements IParameterConsumer {
11 |
12 | protected abstract String getFlag();
13 |
14 | @Override
15 | public void consumeParameters(Stack args, ArgSpec argSpec, CommandSpec commandSpec) {
16 | String flag = getFlag();
17 |
18 | String top = args.pop().trim();
19 | boolean hasFlag = top.startsWith(flag);
20 |
21 | if (hasFlag) {
22 | top = top.substring(1);
23 | }
24 |
25 | Long val;
26 | try {
27 | val = Long.parseLong(top);
28 | } catch(NumberFormatException e) {
29 | throw new RuntimeException(e);
30 | }
31 |
32 | argSpec.setValue(new SimpleEntry<>(hasFlag, val));
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_binding_stream/cli/cmd/CmdSbsSplit.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_binding_stream.cli.cmd;
2 |
3 | import picocli.CommandLine.Command;
4 | import picocli.CommandLine.Option;
5 |
6 | @Command(name = "split", description = "Split/partition bindings into separate files")
7 | public class CmdSbsSplit {
8 | @Option(names = { "-h", "--help" }, usageHelp = true)
9 | public boolean help = false;
10 |
11 | // @Option(names = { "-s", "--sparql" }, description = "SPARQL statement; only queries allowed")
12 | // public List queries;
13 | //
14 | // @Option(names = { "--by" }, description = "Split/Partition by the given variable name (w/o leading '?')")
15 | // public String varName = "srj";
16 | //
17 | //
18 | // @Option(names = { "-o", "--out-format" })
19 | // public String outFormat = "srj";
20 | //
21 | // @Parameters(arity = "0..*", description = "Input files")
22 | // public List nonOptionArgs = new ArrayList<>();
23 | //
24 | // @Override
25 | // public Integer call() throws Exception {
26 | // return SbsCmdImpls.query(this);
27 | // }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/examples/udf.ttl:
--------------------------------------------------------------------------------
1 | @prefix o: .
2 |
3 | # Namespace for functions
4 | @prefix fn: .
5 |
6 | # Resoure namespace, mainly for prefixes
7 | @prefix r: .
8 |
9 |
10 | # Reuse of shacl's prefix vocabulary
11 | @prefix sh: .
12 |
13 | r:prefixMapping
14 | # sh:declare [ sh:prefix "fn" ; sh:namespace fn: ] # shacl apparently does not allow for the shorthand
15 | sh:declare [ sh:prefix "fn" ; sh:namespace "http://www.example.org/" ]
16 | .
17 |
18 | # Convert the first character to uper case and all remaining ones to lower case
19 | fn:ucFirstOnly
20 | a o:UserDefinedFunction ;
21 | sh:prefixes r:prefixMapping ;
22 | o:simpleDefinition ("concat(ucase(substr(str(?x), 1, 1)), lcase(substr(str(?x), 2)))" "x") ;
23 | .
24 |
25 | # BIND(('bob') AS ?greeting) # should return Hello Bob!
26 | fn:sayHello
27 | a o:UserDefinedFunction ;
28 | sh:prefixes r:prefixMapping ;
29 | o:simpleDefinition ("CONCAT('Hello ', fn:ucFirstOnly(?x), '!')" "x") ;
30 | .
31 |
32 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgsSubjects.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.concurrent.Callable;
6 |
7 | import org.aksw.named_graph_stream.cli.main.NgsCmdImpls;
8 |
9 | import picocli.CommandLine.Command;
10 | import picocli.CommandLine.Option;
11 | import picocli.CommandLine.Parameters;
12 |
13 | @Command(name = "subjects", description = "Group triples with consecutive subjects into named graphs")
14 | public class CmdNgsSubjects implements Callable {
15 | @Option(names = { "-h", "--help" }, usageHelp = true)
16 | public boolean help = false;
17 |
18 | @Parameters(arity = "0..*", description = "Input files")
19 | public List nonOptionArgs = new ArrayList<>();
20 |
21 | @Option(names={"-o", "--out-format"})
22 | public String outFormat = "trig/blocks";
23 |
24 | @Override
25 | public Integer call() throws Exception {
26 | return NgsCmdImpls.subjects(this);
27 | }
28 |
29 | // @Parameter(names={"-h", "--help"}, help = true)
30 | // public boolean help = false;
31 | }
32 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgsMerge.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.concurrent.Callable;
6 |
7 | import org.aksw.named_graph_stream.cli.main.NgsCmdImpls;
8 |
9 | import picocli.CommandLine.Command;
10 | import picocli.CommandLine.Option;
11 | import picocli.CommandLine.Parameters;
12 |
13 | /**
14 | * List the top n named graphs
15 | *
16 | * @author raven
17 | *
18 | */
19 | @Command(name = "merge", description = "Not implemented; merge graphs from multiple input file based on a sort key")
20 | public class CmdNgsMerge implements Callable {
21 |
22 | @Option(names = { "-h", "--help" }, usageHelp = true)
23 | public boolean help = false;
24 |
25 | @Option(names = { "-o", "--out-format" })
26 | public String outFormat = "trig/blocks";
27 |
28 | @Parameters(arity = "0..*", description = "Input files")
29 | public List nonOptionArgs = new ArrayList<>();
30 |
31 | @Override
32 | public Integer call() throws Exception {
33 | return NgsCmdImpls.merge(this);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/example.sparql:
--------------------------------------------------------------------------------
1 | #example.sparql
2 | #==============
3 |
4 | PREFIX wgs:
5 | PREFIX q:
6 | CONSTRUCT {
7 | GRAPH eg:myGraph {
8 | ?s
9 | a q:BikeStation ;
10 | q:id ?id ;
11 | rdfs:label ?name ;
12 | wgs:long ?x ;
13 | wgs:lat ?y ;
14 | .
15 | }
16 | }
17 | {
18 | # url:text is a property function that fetches the content of subject URL and
19 | # makes it available as a SPARQL result set row via the object variable
20 | url:text ?src .
21 | BIND(json:parse(?src) AS ?json) .
22 |
23 | # Unnest each item of the json array into its own SPARQL result set row
24 | ?json json:unnest ?i .
25 |
26 | # For each row, craft the values for the CONSTRUCT template
27 | BIND("http://qrowd-project.eu/resource/" AS ?ns)
28 |
29 | BIND(json:path(?i, "$.id") AS ?id)
30 | BIND(URI(CONCAT(?ns, ENCODE_FOR_URI(?id))) AS ?s)
31 | BIND(json:path(?i, "$.name") AS ?name)
32 | BIND(json:path(?i, "$.position[0]") AS ?x)
33 | BIND(json:path(?i, "$.position[1]") AS ?y)
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/docs/graphql/demo.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Online demo
3 | parent: GraphQL over SPARQL
4 | nav_order: 90
5 | layout: default
6 | ---
7 |
8 | The following demonstrators showcase the use of GraphQL to query and present data from a SPARQL enpdoint.
9 | Inspect the source code to see the underlying queries.
10 |
11 | * A simple [WikiData Movies Browser.](https://scaseco.github.io/RdfProcessingToolkit/demos/movies/). This is a HTML one-pager that queries the GraphQL endpoint of a demo RPT instance loaded with movies from Wikidata.
12 |
13 | 
14 |
15 | * A simple [GraphQL-to-GeoJSON Demo.](https://scaseco.github.io/RdfProcessingToolkit/demos/leaflet-graphql/). This is a HTML one-pager that uses GraphQL to transform GeoSPARQL data to a customizable GeoJSON structure. It also demonstrates:
16 | * Ad-hoc simplification of GeoSPARQL polygons using our `geof:simplifyDp` extension function.
17 | * Use of caching cardinalities of properties across a dataset using `SERVICE `, which is part of Apache Jena's [Service Enhancer extension](https://jena.apache.org/documentation/query/service_enhancer.html).
18 |
19 | 
20 |
21 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/rdf_processing_toolkit/cli/cmd/CmdRptMain.java:
--------------------------------------------------------------------------------
1 | package org.aksw.rdf_processing_toolkit.cli.cmd;
2 |
3 | import org.aksw.commons.picocli.CmdCatClasspathResource;
4 | import org.aksw.named_graph_stream.cli.cmd.CmdNgsMain;
5 | import org.aksw.rdf_processing_toolkit.cli.cmd.graphql.CmdGraphQlTkParent;
6 | import org.aksw.rml.cli.cmd.CmdRmlTkParent;
7 | import org.aksw.sparql_binding_stream.cli.cmd.CmdSbsMain;
8 | import org.aksw.sparql_integrate.cli.cmd.CmdRptServe;
9 | import org.aksw.sparql_integrate.cli.cmd.CmdSparqlIntegrateMain;
10 |
11 | import picocli.CommandLine.Command;
12 |
13 | @Command(name="rpt", versionProvider = VersionProviderRdfProcessingToolkit.class, description = "RDF Processing Toolkit", subcommands = {
14 | CmdNgsMain.class,
15 | CmdSparqlIntegrateMain.class,
16 | CmdRptServe.class,
17 | CmdSbsMain.class,
18 | CmdRmlTkParent.class,
19 | // CmdBenchParent.class, Hard-coding benchmarking modules does not really fit RPT - maybe in the future as plugins?
20 | CmdCatClasspathResource.class,
21 | CmdGraphQlTkParent.class
22 | // CmdRml2Exec.class
23 | })
24 | public class CmdRptMain
25 | extends CmdCommonBase
26 | {
27 | }
28 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_binding_stream/cli/cmd/CmdSbsFilter.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_binding_stream.cli.cmd;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.concurrent.Callable;
6 |
7 | import org.aksw.sparql_binding_stream.cli.main.SbsCmdImpls;
8 |
9 | import picocli.CommandLine.Command;
10 | import picocli.CommandLine.Option;
11 | import picocli.CommandLine.Parameters;
12 |
13 |
14 | @Command(name = "filter", description = "Filter bindings by an expression")
15 | public class CmdSbsFilter
16 | implements Callable
17 | {
18 | @Option(names = { "-h", "--help" }, usageHelp = true)
19 | public boolean help = false;
20 |
21 | /**
22 | * sparql-pattern file
23 | *
24 | */
25 | @Option(names = { "-e", "--expr" }, description = "expressions")
26 | public List exprs;
27 | // public long numRecords = 10;
28 |
29 | @Option(names = { "-o", "--out-format" })
30 | public String outFormat = "srj";
31 |
32 | @Parameters(arity = "0..*", description = "Input files")
33 | public List nonOptionArgs = new ArrayList<>();
34 |
35 | @Override
36 | public Integer call() throws Exception {
37 | return SbsCmdImpls.filter(this);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgsGit.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.concurrent.Callable;
6 |
7 | import org.aksw.named_graph_stream.cli.main.NgsGitCmdImpls;
8 |
9 | import picocli.CommandLine.Command;
10 | import picocli.CommandLine.Option;
11 | import picocli.CommandLine.Parameters;
12 |
13 | /**
14 | * List the top n named graphs
15 | *
16 | * @author raven
17 | *
18 | */
19 | @Command(name = "git", description = "List all revisions of a RDF file")
20 | public class CmdNgsGit implements Callable {
21 |
22 | @Option(names = { "-h", "--help" }, usageHelp = true)
23 | public boolean help = false;
24 |
25 | static class ConsumerNumRecords extends IParameterConsumerFlaggedLong {
26 | @Override
27 | protected String getFlag() { return "-"; };
28 | }
29 |
30 | @Option(names = { "-o", "--out-format" })
31 | public String outFormat = "trig/blocks";
32 |
33 | @Parameters(arity = "0..*", description = "Input files")
34 | public List nonOptionArgs = new ArrayList<>();
35 |
36 | @Override
37 | public Integer call() throws Exception {
38 | return NgsGitCmdImpls.git(this);
39 | }
40 | }
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_binding_stream/cli/cmd/CmdSbsMap.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_binding_stream.cli.cmd;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.concurrent.Callable;
6 |
7 | import org.aksw.sparql_binding_stream.cli.main.SbsCmdImpls;
8 |
9 | import picocli.CommandLine.Command;
10 | import picocli.CommandLine.Option;
11 | import picocli.CommandLine.Parameters;
12 |
13 | @Command(name = "map", description = "Map bindings via queries")
14 | public class CmdSbsMap
15 | implements Callable
16 | {
17 |
18 | @Option(names = { "-h", "--help" }, usageHelp = true)
19 | public boolean help = false;
20 |
21 | /**
22 | * sparql-pattern file
23 | *
24 | */
25 | @Option(names = { "-s", "--sparql" }, description = "SPARQL statement; only queries allowed")
26 | public List queries;
27 | // public long numRecords = 10;
28 |
29 | @Option(names = { "-o", "--out-format" })
30 | public String outFormat = "srj";
31 |
32 | @Parameters(arity = "0..*", description = "Input files")
33 | public List nonOptionArgs = new ArrayList<>();
34 |
35 | @Override
36 | public Integer call() throws Exception {
37 | return SbsCmdImpls.query(this);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/rdf_processing_toolkit/cli/main/MainCliRdfProcessingToolkitBase.java:
--------------------------------------------------------------------------------
1 | package org.aksw.rdf_processing_toolkit.cli.main;
2 |
3 | //
4 | //public abstract class MainCliRdfProcessingToolkitBase {
5 | // private static final Logger logger = LoggerFactory.getLogger(MainCliRdfProcessingToolkitBase.class);
6 | //
7 | // static { CliUtils.configureGlobalSettings(); }
8 | //
9 | // protected abstract Object getCommand();
10 | //
11 | // public static void main(String[] args) {
12 | // int exitCode = mainCore(args);
13 | // System.exit(exitCode);
14 | // }
15 | //
16 | // public static int mainCore(String[] args) {
17 | // Object cmd = getCommand();
18 | //
19 | // int result = new CommandLine(cmd)
20 | // .setExecutionExceptionHandler((ex, commandLine, parseResult) -> {
21 | // boolean debugMode = false;
22 | // if (debugMode) {
23 | // ExceptionUtils.rethrowIfNotBrokenPipe(ex);
24 | // } else {
25 | // ExceptionUtils.forwardRootCauseMessageUnless(ex, logger::error, ExceptionUtils::isBrokenPipeException);
26 | // }
27 | // return 0;
28 | // })
29 | // .execute(args);
30 | // return result;
31 | // }
32 | //
33 | //}
34 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgsProbe.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.concurrent.Callable;
6 |
7 | import org.aksw.named_graph_stream.cli.main.NgsCmdImpls;
8 |
9 | import picocli.CommandLine.Command;
10 | import picocli.CommandLine.Option;
11 | import picocli.CommandLine.Parameters;
12 |
13 | /**
14 | * Probe the RDF language of some input by trying out all available parsers
15 | *
16 | * @author raven
17 | *
18 | */
19 | @Command(name = "probe", description = "Determine content type based on input")
20 | public class CmdNgsProbe implements Callable {
21 |
22 | @Option(names = { "-h", "--help" }, usageHelp = true)
23 | public boolean help = false;
24 |
25 | /**
26 | * sparql-pattern file
27 | *
28 | */
29 | // @Parameter(names={"-n"}, description="numRecords")
30 | // public long numRecords = 10;
31 |
32 | // @Parameter(names={"-h", "--help"}, help = true)
33 | // public boolean help = false;
34 |
35 | @Parameters(arity = "0..*", description = "Input files")
36 | public List nonOptionArgs = new ArrayList<>();
37 |
38 | @Override
39 | public Integer call() throws Exception {
40 | return NgsCmdImpls.probe(this);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/rdf_processing_toolkit/cli/cmd/VersionProviderFromClasspathProperties.java:
--------------------------------------------------------------------------------
1 | package org.aksw.rdf_processing_toolkit.cli.cmd;
2 |
3 | import java.io.InputStream;
4 | import java.util.Collection;
5 | import java.util.Objects;
6 | import java.util.Properties;
7 |
8 | import picocli.CommandLine.IVersionProvider;
9 |
10 | /**
11 | * Implementation of picocli's {@link IVersionProvider} that reads the version string
12 | * from an entry of a properties file on the class path with a specific key.
13 | *
14 | * @author raven
15 | *
16 | */
17 | public abstract class VersionProviderFromClasspathProperties implements IVersionProvider {
18 |
19 | public abstract String getResourceName();
20 | public abstract Collection getStrings(Properties properties);
21 |
22 | @Override
23 | public String[] getVersion() throws Exception {
24 | String resourceName = getResourceName();
25 |
26 | Properties properties = new Properties();
27 | try (InputStream in = Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(resourceName),
28 | "Resource not found: " + resourceName)) {
29 | properties.load(in);
30 | }
31 |
32 | String[] result = getStrings(properties).toArray(new String[0]);
33 | return result;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/docs/demos/movies/query.qgl:
--------------------------------------------------------------------------------
1 | query movies
2 | @prefix(map: {
3 | rdfs: "http://www.w3.org/2000/01/rdf-schema#",
4 | xsd: "http://www.w3.org/2001/XMLSchema#",
5 | schema: "http://schema.org/",
6 | wd: "http://www.wikidata.org/entity/"
7 | wdt: "http://www.wikidata.org/prop/direct/"
8 | })
9 | {
10 | # Movies(limit: 10) @pattern(of: "?s wdt:P31 wd:Q11424 . ?s wdt:P2899 [] .", to: "s") {
11 | Movies(limit: 100) @pattern(of: "SELECT ?s { ?s wdt:P31 wd:Q11424 }") {
12 | label @one @pattern(of: "?s rdfs:label ?l. FILTER(LANG(?l) = 'en')")
13 | description @one @pattern(of: "?s schema:description ?l. FILTER(LANG(?l) = 'en')")
14 | depiction @one @pattern(of: "SELECT ?s ?o { ?s wdt:P18 ?o } ORDER BY ?o LIMIT 1")
15 | releaseYear @one @pattern(of: "SELECT ?s (xsd:gYear(MAX(?o)) AS ?date) { ?s wdt:P577 ?o } GROUP BY ?s")
16 | netflix @one @pattern(of: "SELECT ?s ?id { ?s wdt:P1874 ?o . BIND(IRI(CONCAT('https://www.netflix.com/title/', STR(?o))) AS ?id) }")
17 |
18 | # Pick the minimum advised viewing age across based on "wdt:P2899" across any rating scheme
19 | minAge @one @pattern(of: "SELECT ?s (MIN(?o) AS ?age) { ?s (!)/wdt:P2899 ?o } GROUP BY ?s")
20 |
21 | genres @pattern(of: "SELECT DISTINCT ?s (STR(?l) AS ?x) { ?s wdt:P136/rdfs:label ?l . FILTER(langMatches(lang(?l), 'en')) }")
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | title: RDF Processing Toolkit
2 | #remote_theme: pmarsceill/just-the-docs
3 | theme: just-the-docs
4 | url: https://SmartDataAnalytics.github.io
5 |
6 | # plugins:
7 | # - jekyll-default-layout
8 |
9 | #search_enabled: true
10 | # logo: "assets/images/sansa-logo-blue.png"
11 | #markdown: kramdown
12 | #kramdown:
13 | # parse_block_html: true
14 |
15 |
16 | #exclude:
17 | # - sansa*
18 | # - javadoc
19 | # - scaladocs
20 |
21 | # Aux links for the upper right navigation
22 | aux_links:
23 | "GitHub":
24 | - "https://github.com/SmartDataAnalytics/RdfProcessingToolkit"
25 |
26 | # Footer last edited timestamp
27 | last_edit_timestamp: true # show or hide edit time - page must have `last_modified_date` defined in the frontmatter
28 | last_edit_time_format: "%b %e %Y at %I:%M %p" # uses ruby's time format: https://ruby-doc.org/stdlib-2.7.0/libdoc/time/rdoc/Time.html
29 |
30 | # Footer "Edit this page on GitHub" link text
31 | gh_edit_link: true # show or hide edit this page link
32 | gh_edit_link_text: "Edit this page on GitHub."
33 | gh_edit_repository: "https://github.com/SmartDataAnalytics/RdfProcessingToolkit" # the github URL for your repo
34 | gh_edit_branch: "develop" # the branch that your docs is served from
35 | gh_edit_source: "docs" # the source that your files originate from
36 | gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into the editor immediately
37 |
38 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgsWhile.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.concurrent.Callable;
6 |
7 | import org.aksw.named_graph_stream.cli.main.NgsCmdImpls;
8 |
9 | import picocli.CommandLine.Command;
10 | import picocli.CommandLine.Option;
11 | import picocli.CommandLine.Parameters;
12 |
13 | /**
14 | * List the top n named graphs
15 | *
16 | * @author raven
17 | *
18 | */
19 | @Command(name = "while", description = "Yield items up to but excluding the one that satisfies the condition")
20 | public class CmdNgsWhile implements Callable
21 | {
22 |
23 | @Option(names = { "-h", "--help" }, usageHelp = true)
24 | public boolean help = false;
25 |
26 | /**
27 | * sparql-pattern file
28 | *
29 | */
30 | @Option(names={"--sparql"}, description="Ask/Select/Construct query. True or non-empty result set / graph aborts the stream.")
31 | public String sparqlCondition;
32 |
33 | @Option(names={"-o", "--out-format"})
34 | public String outFormat = "trig/blocks";
35 |
36 | @Parameters(arity = "0..*", description = "Input files")
37 | public List nonOptionArgs = new ArrayList<>();
38 |
39 | @Override
40 | public Integer call() throws Exception {
41 | return NgsCmdImpls.xwhile(this);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/resources/log4j2.properties:
--------------------------------------------------------------------------------
1 | dest = err
2 | name = PropertiesConfig
3 |
4 | appender.console.type = Console
5 | appender.console.name = STDERR
6 | appender.console.target = SYSTEM_ERR
7 | appender.console.layout.type = PatternLayout
8 | # appender.console.layout.pattern = [%p] %m%n
9 | appender.console.layout.pattern = %d{HH:mm:ss} %t [%p] [%c{1.}:%L] - %m%n
10 | # appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} [%p] [%c:%L] - %m%n
11 |
12 | rootLogger.level = info
13 | rootLogger.appenderRef.stderr.ref = STDERR
14 |
15 | logger.jetty.name = org.eclipse.jetty
16 | logger.jetty.level = warn
17 |
18 | logger.spring.name = org.springframework
19 | logger.spring.level = warn
20 |
21 | logger.cors.name = org.aksw.jenax.web.filters.CorsFilter
22 | logger.cors.level = warn
23 |
24 | logger.riot.name = org.apache.jena.riot.resultset.rw
25 | logger.riot.level = off
26 |
27 | logger.syntax.name = org.apache.jena.sparql.syntax.syntaxtransform.ElementTransformer
28 | logger.syntax.level = off
29 |
30 | logger.fs.name = org.aksw.jena_sparql_api.sparql.ext.fs.QueryIterServiceOrFile
31 | logger.fs.level = info
32 |
33 | logger.webComponent.name = org.glassfish.jersey.servlet.WebComponent
34 | logger.webComponent.level = off
35 |
36 | # Silence JenaXMLInput Unrecognized property 'http://javax.xml.XMLConstants/property/accessExternalDTD'
37 | logger.jenaUtil.name = org.apache.jena.util
38 | logger.jenaUtil.level = off
39 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgsUntil.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.concurrent.Callable;
6 |
7 | import org.aksw.named_graph_stream.cli.main.NgsCmdImpls;
8 |
9 | import picocli.CommandLine.Command;
10 | import picocli.CommandLine.Option;
11 | import picocli.CommandLine.Parameters;
12 |
13 | /**
14 | * List the top n named graphs
15 | *
16 | * @author raven
17 | *
18 | */
19 | @Command(name = "until", description = "Yield items up to and including the first one that satisfies the condition")
20 | public class CmdNgsUntil implements Callable {
21 |
22 | @Option(names = { "-h", "--help" }, usageHelp = true)
23 | public boolean help = false;
24 |
25 | /**
26 | * sparql-pattern file
27 | *
28 | */
29 | @Option(names = { "--sparql" }, description = "Ask/Select/Construct query. True or non-empty result set / graph aborts the stream.")
30 | public String sparqlCondition;
31 |
32 | @Option(names = { "-o", "--out-format" })
33 | public String outFormat = "trig/blocks";
34 |
35 | // @Parameter(description="Non option args")
36 | @Parameters(arity = "0..*", description = "Input files")
37 | public List nonOptionArgs = new ArrayList<>();
38 |
39 | @Override
40 | public Integer call() throws Exception {
41 | return NgsCmdImpls.until(this);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgsWc.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.concurrent.Callable;
6 |
7 | import org.aksw.named_graph_stream.cli.main.NgsCmdImpls;
8 |
9 | import picocli.CommandLine.Command;
10 | import picocli.CommandLine.Option;
11 | import picocli.CommandLine.Parameters;
12 |
13 | /**
14 | * Count the number of graphs by default, or other aspects based on the
15 | * parameters
16 | *
17 | * @author raven
18 | *
19 | */
20 | @Command(name = "wc", description = "Mimicks the wordcount (wc) command; counts graphs or quads")
21 | public class CmdNgsWc implements Callable {
22 |
23 | @Option(names = { "-h", "--help" }, usageHelp = true)
24 | public boolean help = false;
25 |
26 | @Parameters(arity = "0..*", description = "Input files")
27 | public List nonOptionArgs = new ArrayList<>();
28 |
29 | // TODO We should not use the name 'lines' when we mean triples/quads - maybe
30 | // 'elements' or 'items'?
31 | @Option(names = { "-l", "--lines" }, description = "Count triples/quads instead of graphs")
32 | public boolean numQuads = false;
33 |
34 | @Option(names = { "--nv", "--no-validate" }, description = "Only for nquads: Count lines instead of an actual parse")
35 | public boolean noValidate = false;
36 |
37 | @Override
38 | public Integer call() throws Exception {
39 | return NgsCmdImpls.wc(this);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/docs/rml/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: R2RML and RML
3 | has_children: false
4 | nav_order: 150
5 | layout: default
6 | ---
7 |
8 | # Knowledge Graph Construction with (R2)RML
9 |
10 | RPT can translate RML and R2RML to SPARQL that can be run either with the [`integrate`](../integrate) (single-threaded) or the [`sansa query`](../sansa/query) (multi-threaded) commands.
11 | Note, that the generated SPARQL queries can be also be executed against the SPARQL endpoint launched by `rpt integrate --server`. This can be used to test and inspect individual SPARQL queries and the corresponding (R2)RML mappings.
12 |
13 | ## Basic Usage
14 |
15 | ### Conversion of RML files to SPARQL
16 |
17 | * Convert an RML file to a sequence of SPARQL queries using rmltk's `rml to sparql` command:
18 |
19 | ```bash
20 | rpt rmltk rml to sparql mapping.rml.ttl > mapping.raw.rml.rq
21 | ```
22 |
23 | * Group and/or reorder SPARQL queries using rmltk's `optimize workload` command:
24 |
25 | ```bash
26 | rpt rmltk optimize workload mapping.raw.rml.rq --no-order > mapping.rml.rq
27 | ```
28 |
29 | ### Executing the mapping process
30 |
31 | * ... using the single threaded Jena engine:
32 |
33 | ```bash
34 | rpt integrate mapping.rml.rq
35 | ```
36 |
37 | * Using RPT's parallel Spark-based executor:
38 |
39 | ```bash
40 | rpt sansa query mapping.rml.rq
41 | ```
42 |
43 |
44 | ## Core Technology
45 |
46 | The core technology, i.e. the API and SPARQL converters, are part of our [(R2)RML-Toolkit](https://github.com/Scaseco/R2-RML-Toolkit).
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgsTail.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import java.util.AbstractMap.SimpleEntry;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 | import java.util.Map.Entry;
7 | import java.util.concurrent.Callable;
8 |
9 | import org.aksw.named_graph_stream.cli.main.NgsCmdImpls;
10 |
11 | import picocli.CommandLine.Command;
12 | import picocli.CommandLine.Option;
13 | import picocli.CommandLine.Parameters;
14 |
15 | /**
16 | * List the top n named graphs
17 | *
18 | * @author raven
19 | *
20 | */
21 | @Command(name = "tail", description = "Output the last named graphs")
22 | public class CmdNgsTail implements Callable {
23 |
24 | @Option(names = { "-h", "--help" }, usageHelp = true)
25 | public boolean help = false;
26 |
27 | @Option(names = { "-n" }, parameterConsumer = ConsumerNumRecords.class, description = "numRecords")
28 | public Entry numRecords = new SimpleEntry<>(false, 10l);
29 |
30 | static class ConsumerNumRecords extends IParameterConsumerFlaggedLong {
31 | @Override protected String getFlag() { return "+"; };
32 | }
33 |
34 |
35 | @Option(names = { "-o", "--out-format" })
36 | public String outFormat = "trig/blocks";
37 |
38 | @Parameters(arity = "0..*", description = "Input files")
39 | public List nonOptionArgs = new ArrayList<>();
40 |
41 | @Override
42 | public Integer call() throws Exception {
43 | return NgsCmdImpls.tail(this);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgsFilter.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.concurrent.Callable;
6 |
7 | import org.aksw.named_graph_stream.cli.main.NgsCmdImpls;
8 |
9 | import picocli.CommandLine.Command;
10 | import picocli.CommandLine.Option;
11 | import picocli.CommandLine.Parameters;
12 |
13 | /**
14 | * List the top n named graphs
15 | *
16 | * @author raven
17 | *
18 | */
19 | @Command(name = "filter", description = "Yield items (not) satisfying a given condition")
20 | public class CmdNgsFilter implements Callable {
21 |
22 | @Option(names = { "-h", "--help" }, usageHelp = true)
23 | public boolean help = false;
24 |
25 | /**
26 | * sparql-pattern file
27 | *
28 | */
29 | @Option(names = { "--sparql" }, description = "Ask/Select/Construct query. True or non-empty result set / graph aborts the stream.")
30 | public String sparqlCondition;
31 |
32 |
33 | @Option(names = { "-d", "--drop" }, description = "Invert filter condition; drops matching graphs instead of keeping them")
34 | public boolean drop = false;
35 |
36 | @Option(names = { "-o", "--out-format" })
37 | public String outFormat = "trig/blocks";
38 |
39 | @Parameters(arity = "0..*", description = "Input files")
40 | public List nonOptionArgs = new ArrayList<>();
41 |
42 | @Override
43 | public Integer call() throws Exception {
44 | return NgsCmdImpls.filter(this);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-pkg-parent/rdf-processing-toolkit-pkg-deb-cli/src/deb/control/copyright:
--------------------------------------------------------------------------------
1 | This work was packaged for Debian by:
2 |
3 | Claus Stadler on Tue, 01 Feb 2011 15:37:27 +0100
4 |
5 | It was downloaded from:
6 |
7 |
8 |
9 | Upstream Author(s):
10 |
11 | Claus Stadler
12 |
13 | Copyright:
14 |
15 |
16 |
17 | License:
18 |
19 | This package is free software; you can redistribute it and/or modify
20 | it under the terms of the GNU General Public License version 2 as
21 | published by the Free Software Foundation.
22 |
23 | This package is distributed in the hope that it will be useful,
24 | but WITHOUT ANY WARRANTY; without even the implied warranty of
25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 | GNU General Public License for more details.
27 |
28 | You should have received a copy of the GNU General Public License
29 | along with this program. If not, see
30 |
31 | On Debian systems, the complete text of the GNU General
32 | Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
33 |
34 | The Debian packaging is:
35 |
36 | Copyright (C) 2013 Claus Stadler
37 |
38 | you can redistribute it and/or modify
39 | it under the terms of the GNU General Public License as published by
40 | the Free Software Foundation; either version 2 of the License, or
41 | (at your option) any later version.
42 |
43 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-pkg-parent/rdf-processing-toolkit-pkg-deb-cli/src/deb/resources/usr/bin/rpt:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #WORK_DIR=`dirname "$0"`
4 |
5 | LIB_DIR="/usr/share/rdf-processing-toolkit-cli/"
6 | MAIN_CLASS="org.aksw.rdf_processing_toolkit.cli.main.MainCliRdfProcessingToolkit"
7 |
8 | JAVA=${JAVA_HOME:+$JAVA_HOME/bin/}java
9 |
10 | # Extra options for Java 17; Source: https://stackoverflow.com/questions/73465937/apache-spark-3-3-0-breaks-on-java-17-with-cannot-access-class-sun-nio-ch-direct
11 | # On Java 11 sansa works without these options althought warnings are shown
12 | EXTRA_OPTS="--add-opens=java.base/java.lang=ALL-UNNAMED \
13 | --add-opens=java.base/java.lang.invoke=ALL-UNNAMED \
14 | --add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
15 | --add-opens=java.base/java.io=ALL-UNNAMED \
16 | --add-opens=java.base/java.net=ALL-UNNAMED \
17 | --add-opens=java.base/java.nio=ALL-UNNAMED \
18 | --add-opens=java.base/java.util=ALL-UNNAMED \
19 | --add-opens=java.base/java.util.concurrent=ALL-UNNAMED \
20 | --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED \
21 | --add-opens=java.base/sun.nio.ch=ALL-UNNAMED \
22 | --add-opens=java.base/sun.nio.cs=ALL-UNNAMED \
23 | --add-opens=java.base/sun.security.action=ALL-UNNAMED \
24 | --add-opens=java.base/sun.util.calendar=ALL-UNNAMED \
25 | --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED"
26 |
27 | SCRIPTING_OPTS="-Djena:scripting=true -Dnashorn.args=--language=es6"
28 |
29 | $JAVA $EXTRA_OPTS $SCRIPTING_OPTS $JAVA_OPTS -cp "$LIB_DIR:$LIB_DIR/lib/*:$EXTRA_CP" "$MAIN_CLASS" "$@"
30 |
31 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-pkg-parent/rdf-processing-toolkit-pkg-rpm-cli/src/rpm/resources/usr/bin/rpt:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #WORK_DIR=`dirname "$0"`
4 |
5 | LIB_DIR="/usr/share/rdf-processing-toolkit-cli/"
6 | MAIN_CLASS="org.aksw.rdf_processing_toolkit.cli.main.MainCliRdfProcessingToolkit"
7 |
8 | JAVA=${JAVA_HOME:+$JAVA_HOME/bin/}java
9 |
10 | # Extra options for Java 17; Source: https://stackoverflow.com/questions/73465937/apache-spark-3-3-0-breaks-on-java-17-with-cannot-access-class-sun-nio-ch-direct
11 | # On Java 11 sansa works without these options althought warnings are shown
12 | EXTRA_OPTS="--add-opens=java.base/java.lang=ALL-UNNAMED \
13 | --add-opens=java.base/java.lang.invoke=ALL-UNNAMED \
14 | --add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
15 | --add-opens=java.base/java.io=ALL-UNNAMED \
16 | --add-opens=java.base/java.net=ALL-UNNAMED \
17 | --add-opens=java.base/java.nio=ALL-UNNAMED \
18 | --add-opens=java.base/java.util=ALL-UNNAMED \
19 | --add-opens=java.base/java.util.concurrent=ALL-UNNAMED \
20 | --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED \
21 | --add-opens=java.base/sun.nio.ch=ALL-UNNAMED \
22 | --add-opens=java.base/sun.nio.cs=ALL-UNNAMED \
23 | --add-opens=java.base/sun.security.action=ALL-UNNAMED \
24 | --add-opens=java.base/sun.util.calendar=ALL-UNNAMED \
25 | --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED"
26 |
27 | SCRIPTING_OPTS="-Djena:scripting=true -Dnashorn.args=--language=es6"
28 |
29 | $JAVA $EXTRA_OPTS $SCRIPTING_OPTS $JAVA_OPTS -cp "$LIB_DIR:$LIB_DIR/lib/*:$EXTRA_CP" "$MAIN_CLASS" "$@"
30 |
31 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgsHead.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import java.util.AbstractMap.SimpleEntry;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 | import java.util.Map.Entry;
7 | import java.util.concurrent.Callable;
8 |
9 | import org.aksw.named_graph_stream.cli.main.NgsCmdImpls;
10 |
11 | import picocli.CommandLine.Command;
12 | import picocli.CommandLine.Option;
13 | import picocli.CommandLine.Parameters;
14 |
15 | /**
16 | * List the top n named graphs
17 | *
18 | * @author raven
19 | *
20 | */
21 | @Command(name = "head", description = "List or skip the first n named graphs")
22 | public class CmdNgsHead implements Callable {
23 |
24 | @Option(names = { "-h", "--help" }, usageHelp = true)
25 | public boolean help = false;
26 |
27 | /**
28 | * sparql-pattern file
29 | *
30 | */
31 | @Option(names = { "-n" }, parameterConsumer = ConsumerNumRecords.class, description = "numRecords")
32 | public Entry numRecords = new SimpleEntry<>(false, 10l);
33 |
34 | static class ConsumerNumRecords extends IParameterConsumerFlaggedLong {
35 | @Override
36 | protected String getFlag() { return "-"; };
37 | }
38 |
39 | @Option(names = { "-o", "--out-format" })
40 | public String outFormat = "trig/blocks";
41 |
42 | @Parameters(arity = "0..*", description = "Input files")
43 | public List nonOptionArgs = new ArrayList<>();
44 |
45 | @Override
46 | public Integer call() throws Exception {
47 | return NgsCmdImpls.head(this);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/docs/graphql/README.md:
--------------------------------------------------------------------------------
1 | ## GraphQL to SPARQL Rewriter
2 |
3 |
4 | ### Features
5 |
6 | * **Fully streaming** JSON generation from SPARQL result sets.
7 | * Rewrites GraphQL to a single **SPARQL query**.
8 | * Vendor-independent: The generated SPARQL queries can run on any SPARQL 1.1 \* endpoint.
9 | * Self-contained queries
10 | * No need for expensive schema generation or data summarization
11 | * No need to manage additional mapping files
12 | *
13 |
14 |
15 | ### Limitations and Pitfalls
16 |
17 | * The generated SPARQL query makes use of the LATERAL feature, however this can be polyfilled at the cost of multiple requests with jenax SPARQL polyfills in jenax-dataaccess
18 | * The GraphQL-to-SPARQL rewriter makes the following assumptions:
19 | * Inter-UNION order preservation: Given graph patterns A, B, C, then it is expected that `UNION(A, UNION(B, C))` yields all bindings of A before B, and all bindings of B before C.
20 | * Intra-UNION order preservation: ORDER BY clauses within a union must be preserved.
21 |
22 |
23 | ### Core Concepts
24 |
25 | A GraphQL query is specified by a GraphQL *document* which contains one *query operation definiton*. A *query operation definition* is primarily composed of *fields*, which can have *arguments*, carry annotations called *directives*.
26 |
27 |
28 | ### Mapping SPARQL to JSON
29 |
30 | Each GraphQL field is associated with the following aspects:
31 | * a SPARQL pattern
32 | * of which one list of variables act as the *source* and
33 | * another list of variables that act as the *target*.
34 |
35 |
36 | ```
37 | {
38 |
39 | }
40 | ```
41 |
42 |
43 |
44 | # Reference
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_integrate/cli/main/SansaQueryRewrite.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_integrate.cli.main;
2 |
3 | /**
4 | * Idea to rewrite analytic queries to operations on RDDs.
5 | * If a query only has a BGP that has a star join on the subject then it can
6 | * be executed based on a scan of the subject-graphs of a subject-sorted rdd.
7 | * Certain aggregation over the whole dataset can be rewritten as a
8 | * local aggregation on the subject graph and a global one that accumulates the
9 | * local contributions.
10 | *
11 | */
12 | //public class SansaQueryRewrite
13 | // extends TransformBase
14 | //{
15 | //
16 | //
17 | //
18 | // public static pushGroup(OpGroup op, OpService target) {
19 | // for (ExprAggregator ea : op.getAggregators())
20 | // }
21 | //
22 | // // op.getGroupVars()
23 | //
24 | // }
25 | //
26 | // public static Expr pushAggCount(AggCount agg, Query inner) {
27 | // agg.getExpr();
28 | //
29 | // Expr innerCount = inner.allocAggregate(AggregatorFactory.createCount(false));
30 | // }
31 | //
32 | // public static Expr pushAggSum(AggAvg agg, Query inner) {
33 | // Expr expr = agg.getExprList().get(0);
34 | //
35 | // Expr count = inner.allocAggregate(AggregatorFactory.createCount(false));
36 | // Expr sum = inner.allocAggregate(AggregatorFactory.createSum(false, expr));
37 | //
38 | // Expr result = new E_Conditional(
39 | // E_NotEquals(count, NodeValue.makeInteger(0)),
40 | // new E_Divide(sum, count),
41 | // NodeValue.makeInteger(0));
42 | // return result;
43 | // }
44 | //}
45 |
--------------------------------------------------------------------------------
/docs/integrate/canned-queries.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Canned Queries
3 | parent: RDF/SPARQL Processing
4 | nav_order: 30
5 | layout: default
6 | ---
7 |
8 | ## Canned Queries
9 | RPT ships with several useful queries on its classpath. Classpath resources can be printed out using `cpcat`. The following snippet shows examples of invocations and their output:
10 |
11 | ### Overview
12 | ```bash
13 | $ rpt cpcat spo.rq
14 | CONSTRUCT WHERE { ?s ?p ?o }
15 |
16 | $ rpt cpcat gspo.rq
17 | CONSTRUCT WHERE { GRAPH ?g { ?s ?p ?o } }
18 | ```
19 |
20 | Any resource (query or data) on the classpath can be used as an argument to the `integrate` command:
21 |
22 | ```
23 | rpt integrate yourdata.nt spo.rq
24 | # When spo.rq is executed then the data is queried and printed out on STDOUT
25 | ```
26 |
27 | ### Reference
28 |
29 | The exact definitions can be viewed with `rpt cpcat resource.rq`.
30 |
31 | * `spo.rq`: Output triples from the default graph.
32 | * `gspo.rq`: Output quads from the named graphs.
33 | * `spogspo.rq`: Output all triples followed by all quads.
34 | * `tree.rq`: Deterministically replaces all intermediate nodes with blank nodes. Intermediate nodes are those that appear both as subject and as objects. Useful in conjunction with `--out-format turtle/pretty` for formatting e.g. RML.
35 | * `gtree.rq`: Named graph version of `tree.rq`.
36 | * `rename.rq`: Replaces all occurrences of an IRI in subject and object positions with a different one. Usage (using environment variables): `FROM='urn:from' TO='urn:to' rpt integrate data.nt rename.rq`
37 | * `count.rq`: Return the sum of the counts of triples in the default graph and quads in the named graphs.
38 | * `s.rq`: List the distinct subjects in the default graph.
39 |
40 |
--------------------------------------------------------------------------------
/docs/getting-started/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Getting Started
3 | has_children: true
4 | nav_order: 20
5 | layout: default
6 | ---
7 |
8 | # Getting Started
9 |
10 |
11 |
12 | ### Downloads
13 |
14 | You can download RPT as self-contained JAR bundle, Debian package or RPM package from [RPT's GitHub release page](https://github.com/SmartDataAnalytics/RdfProcessingToolkit/releases).
15 | You can also [build](build) RPT from the source code.
16 |
17 | Note, that several aspects of RPT require appropriate [`--add-opens` JVM option declarations](build.html#jvm-options) to function correctly. The bundles have those proconfigured.
18 |
19 | ### Docker
20 |
21 | The quickest way to start an RPT instance is via docker. The container name is `aksw/rpt`. The latest stable version has the tag `latest` whereas the latest development version is available under `latest-dev`:
22 |
23 | `docker pull aksw/rpt`
24 |
25 | `docker pull aksw/rpt:latest-dev`
26 |
27 |
28 | For example, a typical invocation of the `integrate` command is as follows:
29 |
30 | `docker run -i -p'8642:8642' -v "$(pwd):/data" -w /data aksw/rpt integrate --server YOUR_DATA.ttl`
31 |
32 | * `-p'8642:8642'` exposes RPT's port on the host. The order is `-p PortOnHost:PortInsideContainer`.
33 | * `-v "$(pwd):/data"` mounts the current host directory under `/data` in the container
34 | * `-w /data` sets the container's working directory to `/data`
35 | * `YOUR_DATA.ttl` is foremost a path to a file relative to `/data` in the container. Since `/data` is a mount of your host directory, any relative paths inside your host directory should also work inside the container.
36 |
37 | Visiting [http://localhost:8642/](http://localhost:8642/) should then show RPT's landing page.
38 |
39 |
--------------------------------------------------------------------------------
/docs/graphql/reference/bind.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: bind
3 | parent: GraphQL over SPARQL
4 | nav_order: 130
5 | layout: default
6 | ---
7 |
8 | ## GraphQL Directive: `@bind`
9 |
10 | The `@bind` directive is used to associate a field in your GraphQL query or schema with a SPARQL expression. Note that [`@pattern`](pattern) is for graph patterns rather than expressions.
11 | As bind only produces a single value from the input binding, its cardinality defaults to `@one`. Explicitly adding `@many` will cause the value to be wrapped in an array.
12 |
13 | ### Purpose
14 |
15 | The directive allows one to compute values for a field based on variables that are mentioned in any ancestor node. The most common use is to expose an entity's IRI (or blank node) as an `id` field.
16 |
17 | #### Usage
18 |
19 | The `@bind` directive supports the following arguments:
20 |
21 | - **`of`** (`String`): The value of `of` is a SPARQL expression. The mentioned variables must be defined in any ancestor or at the annotated field.
22 | - **`as`** (`String`): (optional) The variable for the expression result can be specified explicitly (by default an internal name is generated).
23 | - **`target`** (`Boolean`): (optional, defaults to `true`) Whether the `@bind` expression produces the target values for the annotated field.
24 | If `target` is `false` then the field introduces the specified variable that can be referenced from descendants without it becoming a target of the field.
25 | Multiple target variables are combined into a tuple based on the order of their appearance.
26 |
27 | #### Example
28 |
29 | Here is an example demonstrating how to define a `MusicalArtists` field using the `@bind` directive:
30 |
31 | ```graphql
32 | {
33 | MusicalArtists @pattern(of: "?s a ") {
34 | id @bind(of: "?s")
35 | }
36 | }
37 | ```
38 |
39 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-web-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | org.aksw.rdf-processing-toolkit
9 | rdf-processing-toolkit-parent
10 | 1.0.7-SNAPSHOT
11 |
12 |
13 | rdf-processing-toolkit-web-service
14 | jar
15 |
16 |
17 |
18 |
19 | org.aksw.jena-sparql-api
20 | jena-sparql-api-sparql-ext
21 |
22 |
23 |
24 | org.aksw.jena-sparql-api
25 | jena-sparql-api-core
26 |
27 |
28 |
34 |
35 |
36 | org.springframework.boot
37 | spring-boot
38 |
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-autoconfigure
43 |
44 |
45 |
46 | org.springframework.boot
47 | spring-boot-loader
48 |
49 |
50 |
51 | org.slf4j
52 | slf4j-log4j12
53 |
54 |
55 |
56 | junit
57 | junit
58 | test
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/docs/integrate/engines.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Embedded SPARQL Engines
3 | parent: RDF/SPARQL Processing
4 | nav_order: 10
5 | has_children: false
6 | layout: default
7 | ---
8 |
9 | # Embedded SPARQL Engines
10 |
11 | The following engines can be used using `rpt integrate -e engine [--loc engine-specific-location]`.
12 |
13 | Embedded SPARQL engines are built into RPT and thus readily available. The following engines are currently available:
14 |
15 |
16 | | Engine | Description |
17 | | mem | The default in-memory engine based on Apache Jena. Data is discarded once the RPT process terminates. |
18 | | tdb2 | Apache Jena's TDB2 persisent engine. Use --loc to specfify the database folder. |
19 | | binsearch | Binary search engine that operates directly on sorted N-Triples files. Use --loc to specify the file path or HTTP(s) URL to the N-Triples file. For URLs, HTTP range requests must be supported! |
20 | | remote | A pseudo engine that forwards all processing to the SPARQL endpoint whole URL is specified in --loc. |
21 | | qlever | The blazing fast qlever triple store launched from its docker image via Java's TestContainers framework. Use qlever:imageName:tag to use a specific image - this image's command line interfaces for starting the server and creating the indexes must be compatible with the default image registered with RPT. |
22 |
23 |
24 | ### (ARQ) Engine Configuration
25 |
26 | The engines `mem`, `tdb2` and `binsearch` build an Jena's query engine `ARQ` and thus respect its configuration.
27 |
28 | `rpt integrate --set 'arq:queryTimeout=60000' --set 'arq:updateTimeout=1800000' data.ttl myUpdate.ru myQuery.rq`
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/use-case-sportal-analysis/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | # Appenders are output targets
2 | ###############################################################################
3 | # console logging
4 | ###############################################################################
5 | log4j.appender.stderr=org.apache.log4j.ConsoleAppender
6 | log4j.appender.stderr.Target=System.err
7 | log4j.appender.stderr.layout=org.apache.log4j.EnhancedPatternLayout
8 | #log4j.appender.stderr.layout.ConversionPattern=%d [%t] %-5p %c{1.}: %m%n
9 |
10 | #log4j.appender.stderr.layout=org.apache.log4j.PatternLayout
11 | #log4j.appender.stderr.layout.ConversionPattern=%d [%t] %-5p %c: %m%n
12 | #log4j.appender.stderr.layout.ConversionPattern=%d %-5p %c: %m%n
13 | log4j.appender.stderr.layout.ConversionPattern=[%p] %m%n
14 |
15 | ###############################################################################
16 | # Log levels
17 | ###############################################################################
18 | ###
19 | # syntax: log4j.logger.=log-level, [appenders]
20 | # appenders are the output-targets defined above
21 | # loglevels: trace, debug, info, warn, error, fatal
22 | #
23 | log4j.rootLogger=debug, stderr
24 |
25 | log4j.logger.Jena = warn
26 |
27 | log4j.logger.org.apache.http = warn
28 | log4j.logger.org.apache.jena = warn
29 |
30 | log4j.logger.org.eclipse.jetty = warn
31 |
32 | log4j.logger.org.springframework = warn
33 |
34 | log4j.logger.org.aksw.jena_sparql_api.web.filters.CorsFilter = warn
35 |
36 | # Disable annoying message "Attempt to transform a null element - ignored"
37 | log4j.logger.org.apache.jena.sparql.syntax.syntaxtransform.ElementTransformer = off
38 |
39 | log4j.logger.org.aksw.jena_sparql_api.sparql.ext.fs.QueryIterServiceOrFile = info
40 |
41 | #log4j.logger.org.apache.jena.shared.LockMRSW = off
42 | #log4j.logger.org.apache.jena.riot = off
43 |
44 | #log4j.logger.org.apache.jena.sparql.engine.optimizer.reorder = off
45 |
46 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/test/java/org/aksw/sparql_integrate/ngs/cli/main/TestSparqlBindingStreamOperators.java:
--------------------------------------------------------------------------------
1 | package org.aksw.sparql_integrate.ngs.cli.main;
2 |
3 | import org.aksw.commons.picocli.CmdUtils;
4 | import org.aksw.rdf_processing_toolkit.cli.cmd.CliUtils;
5 | import org.aksw.rdf_processing_toolkit.cli.cmd.CmdRptMain;
6 | import org.junit.Test;
7 |
8 | public class TestSparqlBindingStreamOperators {
9 | static { CliUtils.configureGlobalSettings(); }
10 |
11 | @Test
12 | public void test1() {
13 | // TODO Make the output stream of the mainCore functions configurable so that we can intercept the results
14 |
15 | // cat js-query-3.srj | bs query 'SELECT ...'
16 | // bs query -o txt -q 'SELECT (SUM(?X) AS ?sum) ( AS ?Y) {}' js-query-3.srj
17 | CmdUtils.callCmd(CmdRptMain.class, new String[] {"sbs", "map", "-o", "txt", "-s", "SELECT * {}", "js-query-3.srj"});
18 | CmdUtils.callCmd(CmdRptMain.class, new String[] {"sbs", "map", "-o", "txt", "-s", "SELECT (SUM(?X) AS ?sum) {}", "js-query-3.srj"});
19 | CmdUtils.callCmd(CmdRptMain.class, new String[] {"sbs", "map", "-o", "txt", "-s", "SELECT (COUNT(*) AS ?count) {}", "js-query-3.srj"});
20 | CmdUtils.callCmd(CmdRptMain.class, new String[] {"sbs", "map", "-o", "txt", "-s", "SELECT (SUM(?X) AS ?sum) ( AS ?Y) {}", "js-query-3.srj"});
21 |
22 | // TODO Test for expected failures:
23 | // CmdUtils.callCmd(CmdRptMain.class, new String[] {"sbs", "map", "-o", "txt", "-s", "SELECT * {", "js-query-3.srj"});
24 |
25 | // MainCliRdfProcessingToolkit.mainCore(new String[] {"sbs", "query", "-o", "txt", "-q", "SELECT ?x (SUM(?v + 1) AS ?s) {} GROUP BY ?x ORDER BY DESC(SUM(?v))", "/home/raven/Projects/EclipseOld2/jena-asf/jena-arq/testing/ARQ/Optimization/opt-top-03.srj"});
26 | // MainCliRdfProcessingToolkit.mainCore(new String[] {"sbs", "query", "-o", "txt", "-q", "SELECT COUNT(*) {}"});
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/docs/graphql/reference/prefix.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: prefix
3 | parent: GraphQL over SPARQL
4 | nav_order: 100
5 | layout: default
6 | ---
7 |
8 | ## GraphQL Directive: `@prefix`
9 |
10 | The `@prefix` directive is designed to manage and define namespace prefixes in a GraphQL query or schema. This directive can be used to either specify a single prefix with an IRI or map multiple prefixes to their corresponding IRIs.
11 |
12 | ### Usage
13 |
14 | The `@prefix` directive accepts two possible configurations:
15 |
16 | 1. **Single Prefix Definition**: Use the `name` and `iri` arguments to define a single prefix.
17 | 2. **Multiple Prefix Mapping**: Use the `map` argument to define multiple prefixes in a key-value format.
18 |
19 | #### Arguments
20 |
21 | - **`name`** (`String`): The prefix name to be used.
22 | - **`iri`** (`String`): The IRI (Internationalized Resource Identifier) associated with the prefix.
23 | - **`map`** (`Map`): A map of prefix names to their corresponding IRIs.
24 |
25 | #### Examples
26 |
27 | 1. **Single Prefix Definition**
28 |
29 | Define a single prefix using the `name` and `iri` arguments:
30 |
31 | ```graphql
32 | {
33 | field
34 | @prefix(name: "rdf", iri: "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
35 | @prefix(name: "owl", iri: "http://www.w3.org/2002/07/owl#")
36 | }
37 | ```
38 |
39 | 2. **Multiple Prefix Mapping**
40 |
41 | Define multiple prefixes using the `map` argument. As GraphQL does not allow the empty string `""` as a key, the `name/iri` form can be used in conjunction with map:
42 |
43 | ```graphql
44 | query MyQuery
45 | @prefix(map: {
46 | rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
47 | rdfs: "http://www.w3.org/2000/01/rdf-schema#"
48 | }, name: "", iri: "http://my.domain/ontology/)
49 | {
50 | # ...
51 | }
52 | ```
53 |
54 | #### Notes
55 |
56 | - When using the `map` argument, you can define multiple prefix-to-IRI mappings in a single directive instance.
57 |
58 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/main/java/org/aksw/named_graph_stream/cli/cmd/CmdNgsMap.java:
--------------------------------------------------------------------------------
1 | package org.aksw.named_graph_stream.cli.cmd;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.concurrent.Callable;
6 |
7 | import org.aksw.named_graph_stream.cli.main.NgsCmdImpls;
8 |
9 | import picocli.CommandLine.ArgGroup;
10 | import picocli.CommandLine.Command;
11 | import picocli.CommandLine.Option;
12 | import picocli.CommandLine.Parameters;
13 |
14 | @Command(name = "map", description = "(flat-)Map each named graph to a new set of named graphs")
15 | public class CmdNgsMap implements Callable {
16 |
17 | @Option(names = { "-h", "--help" }, usageHelp = true)
18 | public boolean help = false;
19 |
20 |
21 | @ArgGroup(exclusive = true, multiplicity = "1")
22 | public MapSpec mapSpec;
23 |
24 | public static class MapSpec {
25 | /**
26 | * sparql-pattern file
27 | *
28 | */
29 | @Option(names = { "-s", "--sparql" }, description = "sparql file or statement(s)")
30 | public List stmts = new ArrayList<>();
31 |
32 | @Option(names = { "-g", "--graph" }, description = "set the graph of triples or quads")
33 | public String graph = null;
34 |
35 | @Option(names = { "-d", "--dg", "--default-graph" }, description = "map into the default graph")
36 | public boolean defaultGraph = false;
37 | }
38 |
39 | @Option(names = { "-o", "--out-format" }, description = "Output format")
40 | public String outFormat;
41 |
42 |
43 | @Option(names = { "-t", "--service-timeout" }, description = "Connect and/or query timeout in ms. E.g -t 1000 or -t 1000,2000")
44 | public String serviceTimeout = null;
45 |
46 | @Parameters(arity = "0..*", description = "Input files")
47 | public List nonOptionArgs = new ArrayList<>();
48 |
49 | @Override
50 | public Integer call() throws Exception {
51 | return NgsCmdImpls.map(this);
52 | }
53 |
54 | // @Parameter(names={"-h", "--help"}, help = true)
55 | // public boolean help = false;
56 | }
57 |
--------------------------------------------------------------------------------
/rdf-processing-toolkit-cli/src/test/resources/ngs-nato-phonetic-alphabet.trig:
--------------------------------------------------------------------------------
1 | # This document contains a default graph and two named graphs.
2 |
3 | # @base .
4 | @prefix : .
5 | @prefix rdf: .
6 | @prefix dc: .
7 | @prefix foaf: .
8 |
9 |
10 | {
11 | _:a foaf:name "Alfa" .
12 | _:a foaf:mbox .
13 |
14 | :alfario foaf:name "Alfario" .
15 | :alfario foaf:mbox .
16 | :alfario foaf:knows _:b .
17 | }
18 |
19 |
20 | {
21 | _:b foaf:name "Bravo" .
22 | _:b foaf:mbox .
23 | _:b foaf:knows _:b .
24 | }
25 |
26 |
27 | {
28 | _:c foaf:name "Charlie" .
29 | _:c foaf:mbox .
30 | }
31 |
32 |
33 | {
34 | _:d foaf:name "Delta" .
35 | _:d foaf:mbox .
36 | }
37 |
38 |
39 | {
40 | _:e foaf:name "Echo" .
41 | _:e foaf:mbox .
42 | }
43 |
44 |
45 | {
46 | _:f foaf:name "Foxtrot" .
47 | _:f foaf:mbox