-
Notifications
You must be signed in to change notification settings - Fork 62
Add support for Jelly input and output #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ostrzyciel
wants to merge
5
commits into
TopQuadrant:master
Choose a base branch
from
Ostrzyciel:add-jelly
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,6 @@ | |
|
|
||
| # Force Unix bash files to use LF | ||
| *.sh text eol=lf | ||
|
|
||
| # Mark Jelly files as binary | ||
| *.jelly binary | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| * See the NOTICE file distributed with this work for additional | ||
| * information regarding copyright ownership. | ||
| */ | ||
| package org.topbraid.shacl; | ||
|
|
||
| import eu.neverblink.jelly.convert.jena.riot.JellyLanguage; | ||
| import org.apache.jena.util.FileUtils; | ||
| import org.junit.Test; | ||
| import org.topbraid.jenax.util.JenaUtil; | ||
| import org.topbraid.shacl.tools.Infer; | ||
| import org.topbraid.shacl.tools.Validate; | ||
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.io.ByteArrayOutputStream; | ||
| import java.io.PrintStream; | ||
|
|
||
| /** | ||
| * End-to-end tests for the CLI tools that use Jelly as the input and output format. | ||
| * | ||
| * @author Piotr Sowiński | ||
| */ | ||
| public class TestJelly { | ||
|
|
||
| @Test | ||
| public void testJellyInfer() throws Exception { | ||
| String dataFile = this.getClass().getResource("/jelly/infer-data.jelly").getFile(); | ||
| String ruleFile = this.getClass().getResource("/jelly/infer-rule.jelly").getFile(); | ||
|
|
||
| // Redirect System.out to capture the output | ||
| var oldOut = System.out; | ||
| try { | ||
| // Run the rule with Turtle output format | ||
| var turtleOut = new ByteArrayOutputStream(); | ||
| System.setOut(new PrintStream(turtleOut)); | ||
| Infer.main(new String[]{ | ||
| "-datafile", dataFile, | ||
| "-shapesfile", ruleFile, | ||
| "-outputFormat", "ttl" | ||
| }); | ||
|
|
||
| // And with Jelly output | ||
| var jellyOut = new ByteArrayOutputStream(); | ||
| System.setOut(new PrintStream(jellyOut)); | ||
| Infer.main(new String[]{ | ||
| "-datafile", dataFile, | ||
| "-shapesfile", ruleFile, | ||
| "-outputFormat", "jelly" | ||
| }); | ||
|
|
||
| assert(turtleOut.size() > 0); | ||
| assert(jellyOut.size() > 0); | ||
|
|
||
| // Check that the output contains the same number of triples | ||
| var turtleModel = JenaUtil.createDefaultModel().read( | ||
| new ByteArrayInputStream(turtleOut.toByteArray()), null, FileUtils.langTurtle); | ||
| var jellyModel = JenaUtil.createDefaultModel().read( | ||
| new ByteArrayInputStream(jellyOut.toByteArray()), null, JellyLanguage.JELLY.getName()); | ||
| assert(turtleModel.size() == jellyModel.size()); | ||
| } finally { | ||
| System.setOut(oldOut); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testJellyValidate() throws Exception { | ||
| String dataFile = this.getClass().getResource("/jelly/validate-data.jelly").getFile(); | ||
| String shapeFile = this.getClass().getResource("/jelly/validate-shape.jelly").getFile(); | ||
|
|
||
| // Redirect System.out to capture the output | ||
| var oldOut = System.out; | ||
| try { | ||
| // Run the validation with Turtle output format | ||
| var turtleOut = new ByteArrayOutputStream(); | ||
| System.setOut(new PrintStream(turtleOut)); | ||
| Validate.main(new String[]{ | ||
| "-datafile", dataFile, | ||
| "-shapesfile", shapeFile, | ||
| "-outputFormat", "ttl" | ||
| }); | ||
|
|
||
| // Run the validation with Jelly output | ||
| var jellyOut = new ByteArrayOutputStream(); | ||
| System.setOut(new PrintStream(jellyOut)); | ||
| Validate.main(new String[]{ | ||
| "-datafile", dataFile, | ||
| "-shapesfile", shapeFile, | ||
| "-outputFormat", "jelly" | ||
| }); | ||
|
|
||
| assert(turtleOut.size() > 0); | ||
| assert(jellyOut.size() > 0); | ||
|
|
||
| // Check that the output contains the same number of triples | ||
| var turtleModel = JenaUtil.createDefaultModel().read( | ||
| new ByteArrayInputStream(turtleOut.toByteArray()), null, FileUtils.langTurtle); | ||
| var jellyModel = JenaUtil.createDefaultModel().read( | ||
| new ByteArrayInputStream(jellyOut.toByteArray()), null, JellyLanguage.JELLY.getName()); | ||
| assert(turtleModel.size() == jellyModel.size()); | ||
| } finally { | ||
| System.setOut(oldOut); | ||
| } | ||
| } | ||
| } | ||
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| ## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| @prefix osh_kg: <https://ibspan.waw.pl/osh_kg/ontology#> . | ||
| @prefix owl: <http://www.w3.org/2002/07/owl#> . | ||
| @prefix qb: <http://purl.org/linked-data/cube#> . | ||
| @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
| @prefix sdmx-dimension: <http://purl.org/linked-data/sdmx/2009/dimension#> . | ||
| @prefix skos: <http://www.w3.org/2004/02/skos/core#> . | ||
| @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
|
|
||
| sdmx-dimension:refPeriod a qb:DimensionProperty, | ||
| owl:ObjectProperty ; | ||
| rdfs:range osh_kg:YearValue . | ||
|
|
||
| osh_kg:year_2008 a osh_kg:YearValue ; | ||
| rdfs:label "2008"@en, | ||
| "2008"@pl ; | ||
| skos:notation "2008"^^xsd:gYear, | ||
| "2008" . | ||
|
|
||
| osh_kg:year_2009 a osh_kg:YearValue ; | ||
| rdfs:label "2009"@en, | ||
| "2009"@pl ; | ||
| skos:notation "2009"^^xsd:gYear, | ||
| "2009" . | ||
|
|
||
| osh_kg:year_2010 a osh_kg:YearValue ; | ||
| rdfs:label "2010"@en, | ||
| "2010"@pl ; | ||
| skos:notation "2010"^^xsd:gYear, | ||
| "2010" . | ||
|
|
||
| osh_kg:year_2011 a osh_kg:YearValue ; | ||
| rdfs:label "2011"@en, | ||
| "2011"@pl ; | ||
| skos:notation "2011"^^xsd:gYear, | ||
| "2011" . | ||
|
|
||
| osh_kg:year_2012 a osh_kg:YearValue ; | ||
| rdfs:label "2012"@en, | ||
| "2012"@pl ; | ||
| skos:notation "2012"^^xsd:gYear, | ||
| "2012" . | ||
|
|
||
| osh_kg:year_2013 a osh_kg:YearValue ; | ||
| rdfs:label "2013"@en, | ||
| "2013"@pl ; | ||
| skos:notation "2013"^^xsd:gYear, | ||
| "2013" . | ||
|
|
||
| osh_kg:year_2014 a osh_kg:YearValue ; | ||
| rdfs:label "2014"@en, | ||
| "2014"@pl ; | ||
| skos:notation "2014"^^xsd:gYear, | ||
| "2014" . | ||
|
|
||
| osh_kg:year_2015 a osh_kg:YearValue ; | ||
| rdfs:label "2015"@en, | ||
| "2015"@pl ; | ||
| skos:notation "2015"^^xsd:gYear, | ||
| "2015" . | ||
|
|
||
| osh_kg:year_2016 a osh_kg:YearValue ; | ||
| rdfs:label "2016"@en, | ||
| "2016"@pl ; | ||
| skos:notation "2016"^^xsd:gYear, | ||
| "2016" . | ||
|
|
||
| osh_kg:year_2017 a osh_kg:YearValue ; | ||
| rdfs:label "2017"@en, | ||
| "2017"@pl ; | ||
| skos:notation "2017"^^xsd:gYear, | ||
| "2017" . | ||
|
|
||
| osh_kg:year_2018 a osh_kg:YearValue ; | ||
| rdfs:label "2018"@en, | ||
| "2018"@pl ; | ||
| skos:notation "2018"^^xsd:gYear, | ||
| "2018" . | ||
|
|
||
| osh_kg:year_2019 a osh_kg:YearValue ; | ||
| rdfs:label "2019"@en, | ||
| "2019"@pl ; | ||
| skos:notation "2019"^^xsd:gYear, | ||
| "2019" . | ||
|
|
||
| osh_kg:year_2020 a osh_kg:YearValue ; | ||
| rdfs:label "2020"@en, | ||
| "2020"@pl ; | ||
| skos:notation "2020"^^xsd:gYear, | ||
| "2020" . | ||
|
|
||
| osh_kg:year_2021 a osh_kg:YearValue ; | ||
| rdfs:label "2021"@en, | ||
| "2021"@pl ; | ||
| skos:notation "2021"^^xsd:gYear, | ||
| "2021" . | ||
|
|
||
| osh_kg:year_2022 a osh_kg:YearValue ; | ||
| rdfs:label "2022"@en, | ||
| "2022"@pl ; | ||
| skos:notation "2022"^^xsd:gYear, | ||
| "2022" . | ||
|
|
||
| osh_kg:YearValue a owl:Class ; | ||
| rdfs:subClassOf skos:Concept . | ||
|
|
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.