Skip to content

Commit 90e61f1

Browse files
committed
First version as an independent module
0 parents  commit 90e61f1

File tree

2,536 files changed

+114770
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,536 files changed

+114770
-0
lines changed

.gitignore

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
*.class
2+
*.log
3+
.bloop
4+
5+
# sbt specific
6+
dist/*
7+
target/
8+
lib_managed/
9+
src_managed/
10+
project/boot/
11+
project/plugins/project/
12+
13+
# Scala-IDE specific
14+
.scala_dependencies
15+
.metals
16+
.settings
17+
.settings/*
18+
.project
19+
.classpath
20+
.cache
21+
/bin
22+
settings.json
23+
.vscode
24+
.ensime_cache
25+
.ensime
26+
.idea
27+
28+
node_modules/
29+
.grunt
30+
# Logs
31+
logs
32+
npm-debug.log*
33+
yarn-debug.log*
34+
yarn-error.log*
35+
# Runtime data
36+
pids
37+
*.pid
38+
*.seed
39+
*.pid.lock
40+
.npm
41+
*.tgz
42+
43+
*~

.jvmopts

Whitespace-only changes.

.scalafmt.conf

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
style = defaultWithAlign
2+
maxColumn = 120

.travis.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: scala
2+
scala:
3+
- 2.13.0
4+
5+
cache:
6+
directories:
7+
- $HOME/.ivy2/cache
8+
- $HOME/.sbt
9+
10+
before_cache:
11+
# Cleanup the cached directories to avoid unnecessary cache updates
12+
- rm -fv $HOME/.ivy2/.sbt.ivy.lock
13+
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete
14+
- find $HOME/.sbt -name "*.lock" -print -delete
15+
16+
jdk:
17+
- oraclejdk9
18+
- openjdk11

CONTRIBUTING.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Guide for contributors
2+
3+
This project follows a standard [fork and pull][fork-and-pull] model for accepting contributions via
4+
GitHub pull requests:
5+
6+
0. [Pick (or report) an issue](#pick-or-report-an-issue)
7+
1. [Write code](#write-code)
8+
2. [Write tests](#write-tests)
9+
3. [Submit a pull request](#submit-a-pull-request)
10+
11+
## Pick or report an issue
12+
13+
We always welcome bug reports and feature requests—please don't feel like you need to have time to
14+
contribute a fix or implementation for your issue to be appreciated.
15+
16+
## Write code
17+
18+
We prefer functional programming for the code.
19+
20+
* Code and comments should be formatted to a width no greater than 100 columns.
21+
* Files should not contain trailing spaces.
22+
* Imports should be sorted alphabetically.
23+
24+
When in doubt, please run `sbt scalastyle` and let us know if you have any questions.
25+
26+
## Write tests
27+
28+
Shaclex uses [ScalaTest][scalatest] for testing.
29+
30+
## Submit a pull request
31+
32+
* Pull requests should be submitted from a separate branch (e.g. using
33+
`git checkout -b "username/fix-123"`).
34+
* In general we discourage force pushing to an active pull-request branch that other people are
35+
commenting on or contributing to, and suggest using `git merge master` during development.
36+
Once development is complete, use `git rebase master` and force push to [clean up the history][squash].
37+
* The first line of a commit message should be no more than 72 characters long (to accommodate
38+
formatting in various environments).
39+
* Commit messages should general use the present tense, normal sentence capitalization, and no final
40+
punctuation.
41+
* If a pull request decreases code coverage more than by 2%, please file an issue to make sure that
42+
tests get added.
43+
44+
This guide for contributors is inspired by [circe's guide](https://github.com/circe/circe/blob/master/CONTRIBUTING.md).

README.md

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# SHaclEX
2+
3+
Scala implementation of SHEX and SHACL.
4+
5+
This project contains an implementation of
6+
[SHACL](http://w3c.github.io/data-shapes/shacl/) and
7+
[ShEx](http://www.shex.io)
8+
9+
[![Build Status](https://travis-ci.org/weso/shaclex.svg?branch=master)](https://travis-ci.org/labra/shaclex)
10+
[![Codacy Badge](https://api.codacy.com/project/badge/grade/f87bd2ebcfa94dce89e2a981ff13decd)](https://www.codacy.com/app/jelabra/shaclex)
11+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1214239.svg)](https://doi.org/10.5281/zenodo.1214239)
12+
13+
## Introduction
14+
15+
This project contains an implementation of [SHACL](https://www.w3.org/TR/shacl/) and [ShEx](http://shex.io/).
16+
17+
Both are implemented in Scala using the same underlying mechanism using a purely functional approach.
18+
19+
The library handles RDF using a
20+
[simple RDF library](https://github.com/weso/srdf)
21+
which has 2 implementations,
22+
one using [Apache Jena](https://jena.apache.org/)
23+
and another one using [RDF4j](http://rdf4j.org/),
24+
this means that it is possible to use this library to validate RDF models from any of those RDF libraries,
25+
as well as from external SPARQL endpoints.
26+
27+
## Installation and compilation
28+
29+
The project uses [sbt](http://www.scala-sbt.org/) for compilation as well as Java 1.8.
30+
31+
* `sbt test` compiles and runs the tests
32+
33+
## Usage
34+
35+
Once compiled, the program can be run as a command line tool.
36+
It is possible to run the program inside `sbt` as:
37+
38+
### Validating RDF data with SHACL
39+
40+
Example:
41+
42+
```sh
43+
sbt "run --data examples/shacl/good1.ttl
44+
--engine ShaClex"
45+
```
46+
47+
### Validating RDF with ShEx
48+
49+
Example:
50+
51+
```sh
52+
sbt "run --engine=ShEx
53+
--schema examples/shex/good1.shex
54+
--schemaFormat ShExC
55+
--data examples/shex/good1.ttl"
56+
```
57+
58+
### Validating RDF data through an SPARQL endpoint
59+
60+
The following example validates RDF nodes from wikidata using [Gene-wiki ShEx](https://github.com/SuLab/Genewiki-ShEx):
61+
62+
```sh
63+
sbt "run --endpoint=https://query.wikidata.org/sparql
64+
--schemaUrl=https://raw.githubusercontent.com/SuLab/Genewiki-ShEx/master/diseases/wikidata-disease-ontology.shex
65+
--shapeMap=examples/shex/wikidata/disease1.shapeMap
66+
--schemaFormat=ShExC
67+
--engine=ShEx
68+
--trigger=ShapeMap
69+
--showResult
70+
--resultFormat=JSON"
71+
```
72+
73+
74+
### Interactive mode with `sbt`
75+
76+
It is usually faster to run the `sbt` command, which opens the interactive `sbt` shell and inside that shell, execute
77+
the different commands.
78+
79+
```sh
80+
$ sbt
81+
... several information about loading libraries
82+
sbt> run -d examples/shacl/good1.ttl --engine ShaClex
83+
```
84+
85+
### Binary mode
86+
87+
The fastest way to run Shaclex is to compile the code and generate a binary.
88+
The following command:
89+
90+
```sh
91+
$ sbt universal:packageBin
92+
...generates the file...
93+
target/universal/shaclex-N.N.N.zip
94+
```
95+
96+
which contains the compressed binary code.
97+
98+
## Implementation details
99+
100+
* The engine is based on Monads using the [cats library](http://typelevel.org/cats/)
101+
* The ShEx compact syntax parser
102+
is implemented using the following [Antlr grammar](https://github.com/shexSpec/grammar/blob/master/ShExDoc.g4) (previous versions used Scala Parser Combinators)
103+
which is based on this [grammar](https://github.com/shexSpec/shex.js/blob/master/doc/bnf)
104+
* JSON encoding and decoding uses the Json structure [defined here](https://shexspec.github.io/spec/) and is implemented using [Circe](https://github.com/travisbrown/circe)
105+
106+
## Compatibility tests
107+
108+
The current implementation passes all [shacl-core tests](https://w3c.github.io/data-shapes/data-shapes-test-suite/).
109+
In order to generate the EARL report, run:
110+
111+
```
112+
$ sbt
113+
[...]
114+
sbt:shaclex> project shacl
115+
sbt:shacl> testOnly es.weso.shacl.report.ReportGeneratorCompatTest
116+
```
117+
118+
We also aim to pass the [ShEx test-suite](https://github.com/shexSpec/shexTest).
119+
120+
In order to run the shex test-suite and generate the EARL report, you can do the following:
121+
122+
```
123+
sbt
124+
...
125+
sbt:shaclex> project shex
126+
sbt:shex> compat:test
127+
```
128+
129+
## Convert between Schema formats
130+
131+
Shaclex can be used to convert between different schemas.
132+
The following example shows how to convert between ShExC to ShExJ:
133+
134+
```
135+
$ sbt "run --schema examples/shex/good1.shex
136+
--schemaFormat ShExC
137+
--outSchemaFormat ShExJ
138+
--showSchema"
139+
```
140+
141+
## More information
142+
143+
* The aim of Shaclex is to support both ShEx and SHACL and to provide conversions between both languages.
144+
More information about both languages can be read in the [Validating RDF data](http://book.validatingrdf.com) written by the authors.
145+
* An online demo based on this library is available at [http://rdfshape.weso.es](http://rdfshape.weso.es).
146+
* Another online demo based on this library customized for Wikidata is available at [http://wikidata.weso.es](http://wikidata.weso.es).
147+
* This project was based on [ShExcala](http://labra.github.io/ShExcala/) which was focused on Shape Expressions only.
148+
149+
## Author & contributors
150+
151+
* Author: [Jose Emilio Labra Gayo](http://labra.weso.es)
152+
153+
Contributors:
154+
155+
* [Eric Prud'hommeaux](https://www.w3.org/People/Eric/)
156+
* [Bogdan Roman](https://github.com/bogdanromanx)
157+
* [Toni Cebrían](http://www.tonicebrian.com/)
158+
* [Andrew Berezovskyi](https://github.com/berezovskyi)
159+
160+
## Adopters
161+
162+
* [RDFShape](http://rdfshape.weso.es): An online demo powered by this library.
163+
* [Wikishape](http://wikishape.weso.es): An online demo powered by this library for Wikidata.
164+
* [Eclipse lyo](http://www.eclipse.org/lyo/): An SDK and a modelling environment to design and develop linked data applications based on the [OSLC standards](http://open-services.net/). The validation library is [lyo-validation](https://github.com/eclipse/lyo-validation).
165+
166+
## Contribution
167+
168+
Contributions are greatly appreciated.
169+
Please fork this repository and open a
170+
pull request to add more features or [submit issues](https://github.com/labra/shaclex/issues)

0 commit comments

Comments
 (0)