Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/imas/rdflint
RDF linter
https://github.com/imas/rdflint
Last synced: 5 days ago
JSON representation
RDF linter
- Host: GitHub
- URL: https://github.com/imas/rdflint
- Owner: imas
- License: mit
- Created: 2018-11-25T12:47:27.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-07-12T04:13:37.000Z (over 1 year ago)
- Last Synced: 2024-08-01T12:29:41.963Z (3 months ago)
- Language: Java
- Homepage: https://imas.github.io/rdflint/
- Size: 818 KB
- Stars: 46
- Watchers: 10
- Forks: 6
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - imas/rdflint - RDF linter (others)
README
rdflint
---[![JitPack](https://jitpack.io/v/imas/rdflint.svg)](https://jitpack.io/#imas/rdflint)
[![Marketplace Version](https://vsmarketplacebadge.apphb.com/version/takemikami.vscode-rdflint.svg "Current Release")](https://marketplace.visualstudio.com/items?itemName=takemikami.vscode-rdflint)
[![Setup rdflint](https://img.shields.io/badge/GitHub_Marketplace-Setup_rdflint-light_green)](https://github.com/marketplace/actions/setup-rdflint)
[![ci](https://github.com/imas/rdflint/actions/workflows/ci.yaml/badge.svg)](https://github.com/imas/rdflint/actions/workflows/ci.yaml)[rdflint Users Guide](https://imas.github.io/rdflint/)
Note. Currencty translate to English from Japanese. Some part is still in Japanese.## What's rdflint
rdflint is a linter for RDF files. Easy to check syntax and other things. rdflint is powered by [Apache Jena](https://jena.apache.org/).
rdflint has following functions.
- Syntax check of rdf and Turtle(ttl).
- Undefined subject check when use as predicate or object.
- Custom check by SPARQL query.
- Degrade validation.
- Datatype & outlier validation.
- SHACL constraint validation.
- Literal trim validation.
- File encoding validation.
- RDF generation by SPARQL query results.
- SPARQL playground on your PC. (Interactive Mode)## Getting Started
### Work on Visual Studio Code
Use [vscode-rdflint](vscode-rdflint/README.md)
### Work on your PC
Download from jitpack.
```
$ wget https://jitpack.io/com/github/imas/rdflint/0.2.1/rdflint-0.2.1.jar
```Run for apply to your RDF files.
```
$ java -jar rdflint-0.2.1.jar -targetdir example/dataset
`````-targetdir`` parameter is location of target RDF files.
### Work on GitHub Actions
Make ``.github/workflows/ci.yml`` to your repository. Its contents is following.
```
name: CI
on: pull_request
jobs:
rdflint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11
- uses: imas/setup-rdflint@v1
- name: Run rdflint
run: rdflint
```See [imas/setup-rdflint](https://github.com/imas/setup-rdflint) for more information.
## Configurations
When create a configuration file of rdflint, rdflint provide additional checks. Run with ``-config`` parameter like following.
```
$ java -jar rdflint-0.2.1.jar -targetdir example/dataset -config example/dataset/rdflint-config.yml
`````-config`` parameter is location of rdflint configuration file.
### Undefined subject checks
Write configuration file like a following.
```
baseUri: https://sparql.crssnky.xyz/imasrdf/
```And check undefined subject under baseUri, when use as predicate or object.
### SPARQL based custom checks
Write configuration file like a following.
```
rules:
- name: file class
target: "RDFs/765AS.rdf"
query: |
PREFIX rdf:
SELECT ?s ?o
WHERE {
?s rdf:type ?o .
FILTER NOT EXISTS {
?s rdf:type
}
}
valid: |
while(rs.hasNext()) {
log.warn("Idol definition file " + rs.next())
}
```And run SPARQL query of ``rules-query`` to target file of ``rules-target``. Groovy script of ``rules-valid`` apply to result set of query.
### Degrade validation
Run with ``-origindir`` parameter like following.
```
$ java -jar rdflint-0.2.1.jar -targetdir example/dataset -origindir example/dataset_origin -config example/dataset/rdflint-config.yml
```And check subject and triple, removed from origindir. Its problem report as INFO level.
### SHACL constraint validation
write your SHACL constraint in `.ttl` or `.rdf` file.
and put this file in directory which specified by `-targetdir`.### RDF generation
Write configuration file like a following.
```
baseUri: https://sparql.crssnky.xyz/imasrdf/
generation:
- query: |
PREFIX schema:
PREFIX rdf:
PREFIX imas:
SELECT ?m (group_concat(?s;separator=",,,,,")as ?u)
WHERE {
?s rdf:type imas:Unit;
schema:member ?m.
}group by (?m) order by (?m)
template: .circleci/Unit_memberOf.rdf.template
output: RDFs/Unit_memberOf.rdf
```Write template file like a following.
```
[# th:each="idol : ${rs}"]
[# th:each="item : ${idol.u.split(',,,,,')}"]
[/]
[/]
```And generate rdf file like a following.
```
....
```## Interactive Mode
Run interactive mode with ``-i`` parameter.
```
$ java -jar rdflint-0.2.1.jar -i -targetdir example/dataset -config example/dataset/rdflint-config.yml
```And try to query. Double return to perform query, type ``:exit`` to exit interactive mode.
```
sparql > PREFIX rdf:
> SELECT ?s
> WHERE {
> ?s rdf:type .
> }
>
---------------------------------------------------------------------
| s |
=====================================================================
| |
| |
| |
........
```## Contributing
Please fork this repository, and create pull request for contributing.
### Build and execute
Build rdflint with gradle.
```
$ gradle shadowJar
```Run rdflint.
```
$ java -jar build/libs/rdflint.jar -targetdir example/dataset
```### IDE Settings
Use [dotidea](https://github.com/imas/rdflint/tree/dotidea) - Project Settings for IntelliJ IDEA.
## License
rdflint is released under the [MIT License](https://github.com/imas/rdflint/blob/master/LICENSE).