Giter VIP home page Giter VIP logo

shex-s's Introduction

ShEx-s

Scala implementation of SHEX.

This project contains an implementation of Shape Expressions (ShEx).

Continuous Integration Codacy Badge codecov Maven Central

Introduction

This project contains a Scala implementation of ShEx. The library handles RDF using a simple RDF library, which at this moment has 2 implementations, one using Apache Jena and another one using RDF4j. This means that it is possible to use this library to validate RDF models from either Jena or RDF4J models, as well as from external SPARQL endpoints.

Installation and compilation

The project uses sbt for compilation as well as Java 1.8.

  • sbt test compiles and runs the tests

Command line usage

It is possible to run shex-s as a command line tool.

To create the executable you have to install scala-cli and once it is installed run the following command in the folder with the shexs repository:

$ scala-cli package . -o shexs -f

which will create an executable called shexs

Usage:
    shexs mapping
    shexs validate
    shexs shapePath
    shexs manifest
    shexs wikibase
    shexs schema

ShEx-Scala command line tool

Options and flags:
    --help
        Display this help text.
    --version, -v
        Print the version number and exit.

Subcommands:
    mapping
        Convert a schema through a mapping
    validate
        Validate RDF data using a schema and a shape map
    shapePath
        Validate a shape path
    manifest
        Run manifest file containing tests
    wikibase
        Validate RDF data from wikibase
    schema
        Schema processing actions

It is possible to create binaries for different platforms like Linux, Windows, MacOS, etc. We would like to publish those binaries with each release as discribed in this issue.

Validate option

You can run the following in the examples folder to validate the turtle file user.ttl according to the ShEx file user.shex and the shape map user.sm:

shexs validate --schema user.shex --data user.ttl --shapeMap user.sm

Other options for validation are available as:

Usage:
    shexs validate --schema <path> [--schemaFormat <format>] [--baseIRI <string>] --data <path> [--dataFormat <string>] --shapeMap <path> [--shapeMapFormat <string>] [--validator version <string>] [--showResultFormat <string>] [--output <path>] [--verbose <string>]
    shexs validate --schema <path> [--schemaFormat <format>] [--baseIRI <string>] --endpoint <string> --shapeMap <path> [--shapeMapFormat <string>] [--validator version <string>] [--showResultFormat <string>] [--output <path>] [--verbose <string>]
    shexs validate --schemaURL <string> [--baseIRI <string>] --data <path> [--dataFormat <string>] --shapeMap <path> [--shapeMapFormat <string>] [--validator version <string>] [--showResultFormat <string>] [--output <path>] [--verbose <string>]
    shexs validate --schemaURL <string> [--baseIRI <string>] --endpoint <string> --shapeMap <path> [--shapeMapFormat <string>] [--validator version <string>] [--showResultFormat <string>] [--output <path>] [--verbose <string>]

Validate RDF data using a schema and a shape map

Options and flags:
    --help
        Display this help text.
    --schema <path>, -s <path>
        Path to ShEx file.
    --schemaFormat <format>
        Schema format, default = (ShExC). Possible values = (ShExC,ShExJ)
    --baseIRI <string>
        base IRI
    --schemaURL <string>
        URL of schema
    --data <path>, -d <path>
        Path to data file.
    --dataFormat <string>
        Data format. Default=Turtle, available=Turtle,NTriples,RDF/XML,JSON-LD
    --endpoint <string>
        endpoint URL
    --shapeMap <path>, -s <path>, -m <path>
        Path to shapeMap file.
    --shapeMapFormat <string>
        ShapeMap format, default=Compact, available formats=List(Compact, JSON)
    --validator version <string>, -e <string>
        version of validator. Default = 2.2. Other values = 2.1,ref
    --showResultFormat <string>
        showResultFormat
    --output <path>
        Output to file (default = console)
    --verbose <string>, -v <string>
        verbose level (0-nothing,1-basic,2-info,3-details,4-debug,5-step,6-all)

Implementation details

  • The engine is based on Monads using the cats library
  • The ShEx compact syntax parser is implemented using the following Antlr grammar (previous versions used Scala Parser Combinators) which is based on this grammar
  • JSON encoding and decoding uses the Json structure defined here and is implemented using Circe
  • It supports ShEx + extends

Compatibility tests

We also pass the ShEx test-suite.

Generating docs page

Publishing to OSS-Sonatype

This project uses the sbt ci release plugin for publishing to OSS Sonatype.

SNAPSHOT Releases

Open a PR and merge it to watch the CI release a -SNAPSHOT version

Full Library Releases
  1. Push a tag and watch the CI do a regular release
  2. git tag -a v0.1.0 -m "v0.1.0"
  3. git push origin v0.1.0 Note that the tag version MUST start with v.

More information

Author & contributors

Contributors:

Adopters

  • RDFShape: An online demo powered by this library.
  • Wikishape: An online demo powered by this library for Wikidata.
  • Eclipse lyo: An SDK and a modelling environment to design and develop linked data applications based on the OSLC standards. The validation library is lyo-validation.

Contribution

Contributions are greatly appreciated. Please fork this repository and open a pull request to add more features or submit issues

shex-s's People

Contributors

dependabot[bot] avatar labra avatar locke avatar markiantorno avatar scala-steward avatar ulitol97 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

shex-s's Issues

Docs automation

The documentation of the project will be available at: https://www.weso.es/shex-s/

We want to have the following features:

  • Automatic generation of ScalaDoc. Currently available at API Docs
  • Examples about how to invoke the library in Scala that are automatically compiled and checked that they run
  • Some description of the architecture in markdown
  • Automatic generation of the documentation. Currently with sbt docs/mdoc
  • Automatic creation of website. It should be done with sbt docusaurusCreateSite
  • Automatic publication of the documentation. It should be done with sbt docusaurusPublishSite. It is failing, there seems to be an error in ssh deploy_key.

sbt test error

% sbt test
error:
  bad constant pool index: 0 at pos: 48461
     while compiling: <no file>
        during phase: globalPhase=<no phase>, enteringPhase=<some phase>
     library version: version 2.12.17
    compiler version: version 2.12.17
  reconstructed args: -classpath /Users/ar/.sbt/boot/scala-2.12.17/lib/scala-library.jar -Yrangepos

  last tree to typer: EmptyTree
       tree position: <unknown>
            tree tpe: <notype>
              symbol: null
           call site: <none> in <none>

== Source file context for tree position ==

error:
  bad constant pool index: 0 at pos: 48461
     while compiling: <no file>
        during phase: globalPhase=<no phase>, enteringPhase=<some phase>
     library version: version 2.12.17
    compiler version: version 2.12.17
  reconstructed args: -classpath /Users/ar/.sbt/boot/scala-2.12.17/lib/scala-library.jar -Yrangepos

  last tree to typer: EmptyTree
       tree position: <unknown>
            tree tpe: <notype>
              symbol: null
           call site: <none> in <none>

== Source file context for tree position ==

Exception in thread "sbt-parser-init-thread" java.lang.ExceptionInInitializerError
	at sbt.internal.parser.SbtParserInit$$anon$2.run(SbtParser.scala:191)
Caused by: scala.reflect.internal.FatalError:
  bad constant pool index: 0 at pos: 48461
     while compiling: <no file>
        during phase: globalPhase=<no phase>, enteringPhase=<some phase>
     library version: version 2.12.17
    compiler version: version 2.12.17
  reconstructed args: -classpath /Users/ar/.sbt/boot/scala-2.12.17/lib/scala-library.jar -Yrangepos

  last tree to typer: EmptyTree
       tree position: <unknown>
            tree tpe: <notype>
              symbol: null
           call site: <none> in <none>

== Source file context for tree position ==


	at scala.reflect.internal.Reporting.abort(Reporting.scala:69)
	at scala.reflect.internal.Reporting.abort$(Reporting.scala:65)
	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:28)
	at scala.tools.nsc.symtab.classfile.ClassfileParser$ConstantPool.errorBadIndex(ClassfileParser.scala:385)
	at scala.tools.nsc.symtab.classfile.ClassfileParser$ConstantPool.getExternalName(ClassfileParser.scala:249)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.readParamNames$1(ClassfileParser.scala:828)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.parseAttribute$1(ClassfileParser.scala:834)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.$anonfun$parseAttributes$7(ClassfileParser.scala:908)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.parseAttributes(ClassfileParser.scala:908)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.parseMethod(ClassfileParser.scala:611)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.$anonfun$parseClass$4(ClassfileParser.scala:534)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.parseClass(ClassfileParser.scala:534)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.$anonfun$parse$2(ClassfileParser.scala:160)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.$anonfun$parse$1(ClassfileParser.scala:146)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.parse(ClassfileParser.scala:129)
	at scala.tools.nsc.symtab.SymbolLoaders$ClassfileLoader.doComplete(SymbolLoaders.scala:343)
	at scala.tools.nsc.symtab.SymbolLoaders$SymbolLoader.complete(SymbolLoaders.scala:250)
	at scala.reflect.internal.Symbols$Symbol.completeInfo(Symbols.scala:1542)
	at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1514)
	at scala.reflect.internal.Definitions.scala$reflect$internal$Definitions$$enterNewMethod(Definitions.scala:49)
	at scala.reflect.internal.Definitions$DefinitionsClass.String_$plus$lzycompute(Definitions.scala:1134)
	at scala.reflect.internal.Definitions$DefinitionsClass.String_$plus(Definitions.scala:1134)
	at scala.reflect.internal.Definitions$DefinitionsClass.syntheticCoreMethods$lzycompute(Definitions.scala:1438)
	at scala.reflect.internal.Definitions$DefinitionsClass.syntheticCoreMethods(Definitions.scala:1420)
	at scala.reflect.internal.Definitions$DefinitionsClass.symbolsNotPresentInBytecode$lzycompute(Definitions.scala:1450)
	at scala.reflect.internal.Definitions$DefinitionsClass.symbolsNotPresentInBytecode(Definitions.scala:1450)
	at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1506)
	at scala.tools.nsc.Global$Run.<init>(Global.scala:1214)
	at sbt.internal.parser.SbtParser$.<init>(SbtParser.scala:141)
	at sbt.internal.parser.SbtParser$.<clinit>(SbtParser.scala)
	... 1 more
[info] welcome to sbt 1.8.0 (Homebrew Java 21.0.3)
java.lang.NoClassDefFoundError: Could not initialize class sbt.internal.parser.SbtParser$
	at sbt.internal.parser.SbtParser.splitExpressions(SbtParser.scala:247)
	at sbt.internal.parser.SbtParser.<init>(SbtParser.scala:236)
	at sbt.internal.EvaluateConfigurations$.splitExpressions(EvaluateConfigurations.scala:289)
	at sbt.internal.EvaluateConfigurations$.parseConfiguration(EvaluateConfigurations.scala:98)
	at sbt.internal.EvaluateConfigurations$.evaluateSbtFile(EvaluateConfigurations.scala:147)
	at sbt.internal.Load$.loadSettingsFile$1(Load.scala:1118)
	at sbt.internal.Load$.$anonfun$discoverProjects$2(Load.scala:1128)
	at scala.collection.MapLike.getOrElse(MapLike.scala:131)
	at scala.collection.MapLike.getOrElse$(MapLike.scala:129)
	at scala.collection.AbstractMap.getOrElse(Map.scala:65)
	at sbt.internal.Load$.memoLoadSettingsFile$1(Load.scala:1127)
	at sbt.internal.Load$.$anonfun$discoverProjects$4(Load.scala:1135)
	at scala.collection.immutable.List.map(List.scala:293)
	at sbt.internal.Load$.loadFiles$1(Load.scala:1135)
	at sbt.internal.Load$.discoverProjects(Load.scala:1149)
	at sbt.internal.Load$.discover$1(Load.scala:901)
	at sbt.internal.Load$.loadTransitive(Load.scala:955)
	at sbt.internal.Load$.loadProjects$1(Load.scala:738)
	at sbt.internal.Load$.$anonfun$loadUnit$12(Load.scala:741)
	at sbt.internal.Load$.timed(Load.scala:1406)
	at sbt.internal.Load$.$anonfun$loadUnit$1(Load.scala:741)
	at sbt.internal.Load$.timed(Load.scala:1406)
	at sbt.internal.Load$.loadUnit(Load.scala:694)
	at sbt.internal.Load$.$anonfun$builtinLoader$4(Load.scala:492)
	at sbt.internal.BuildLoader$.$anonfun$componentLoader$5(BuildLoader.scala:180)
	at sbt.internal.BuildLoader.apply(BuildLoader.scala:245)
	at sbt.internal.Load$.loadURI$1(Load.scala:554)
	at sbt.internal.Load$.loadAll(Load.scala:570)
	at sbt.internal.Load$.loadURI(Load.scala:500)
	at sbt.internal.Load$.load(Load.scala:479)
	at sbt.internal.Load$.$anonfun$apply$1(Load.scala:241)
	at sbt.internal.Load$.timed(Load.scala:1406)
	at sbt.internal.Load$.apply(Load.scala:241)
	at sbt.internal.Load$.buildPluginDefinition(Load.scala:1323)
	at sbt.internal.Load$.buildPlugins(Load.scala:1253)
	at sbt.internal.Load$.plugins(Load.scala:1232)
	at sbt.internal.Load$.$anonfun$loadUnit$2(Load.scala:700)
	at sbt.internal.Load$.timed(Load.scala:1406)
	at sbt.internal.Load$.$anonfun$loadUnit$1(Load.scala:700)
	at sbt.internal.Load$.timed(Load.scala:1406)
	at sbt.internal.Load$.loadUnit(Load.scala:694)
	at sbt.internal.Load$.$anonfun$builtinLoader$4(Load.scala:492)
	at sbt.internal.BuildLoader$.$anonfun$componentLoader$5(BuildLoader.scala:180)
	at sbt.internal.BuildLoader.apply(BuildLoader.scala:245)
	at sbt.internal.Load$.loadURI$1(Load.scala:554)
	at sbt.internal.Load$.loadAll(Load.scala:570)
	at sbt.internal.Load$.loadURI(Load.scala:500)
	at sbt.internal.Load$.load(Load.scala:479)
	at sbt.internal.Load$.$anonfun$apply$1(Load.scala:241)
	at sbt.internal.Load$.timed(Load.scala:1406)
	at sbt.internal.Load$.apply(Load.scala:241)
	at sbt.internal.Load$.buildPluginDefinition(Load.scala:1323)
	at sbt.internal.Load$.buildPlugins(Load.scala:1253)
	at sbt.internal.Load$.plugins(Load.scala:1232)
	at sbt.internal.Load$.$anonfun$loadUnit$2(Load.scala:700)
	at sbt.internal.Load$.timed(Load.scala:1406)
	at sbt.internal.Load$.$anonfun$loadUnit$1(Load.scala:700)
	at sbt.internal.Load$.timed(Load.scala:1406)
	at sbt.internal.Load$.loadUnit(Load.scala:694)
	at sbt.internal.Load$.$anonfun$builtinLoader$4(Load.scala:492)
	at sbt.internal.BuildLoader$.$anonfun$componentLoader$5(BuildLoader.scala:180)
	at sbt.internal.BuildLoader.apply(BuildLoader.scala:245)
	at sbt.internal.Load$.loadURI$1(Load.scala:554)
	at sbt.internal.Load$.loadAll(Load.scala:570)
	at sbt.internal.Load$.loadURI(Load.scala:500)
	at sbt.internal.Load$.load(Load.scala:479)
	at sbt.internal.Load$.$anonfun$apply$1(Load.scala:241)
	at sbt.internal.Load$.timed(Load.scala:1406)
	at sbt.internal.Load$.apply(Load.scala:241)
	at sbt.internal.Load$.buildPluginDefinition(Load.scala:1323)
	at sbt.internal.Load$.buildPlugins(Load.scala:1253)
	at sbt.internal.Load$.plugins(Load.scala:1232)
	at sbt.internal.Load$.$anonfun$loadUnit$2(Load.scala:700)
	at sbt.internal.Load$.timed(Load.scala:1406)
	at sbt.internal.Load$.$anonfun$loadUnit$1(Load.scala:700)
	at sbt.internal.Load$.timed(Load.scala:1406)
	at sbt.internal.Load$.loadUnit(Load.scala:694)
	at sbt.internal.Load$.$anonfun$builtinLoader$4(Load.scala:492)
	at sbt.internal.BuildLoader$.$anonfun$componentLoader$5(BuildLoader.scala:180)
	at sbt.internal.BuildLoader.apply(BuildLoader.scala:245)
	at sbt.internal.Load$.loadURI$1(Load.scala:554)
	at sbt.internal.Load$.loadAll(Load.scala:570)
	at sbt.internal.Load$.loadURI(Load.scala:500)
	at sbt.internal.Load$.load(Load.scala:479)
	at sbt.internal.Load$.$anonfun$apply$1(Load.scala:241)
	at sbt.internal.Load$.timed(Load.scala:1406)
	at sbt.internal.Load$.apply(Load.scala:241)
	at sbt.internal.Load$.defaultLoad(Load.scala:56)
	at sbt.BuiltinCommands$.liftedTree1$1(Main.scala:961)
	at sbt.BuiltinCommands$.doLoadProject(Main.scala:961)
	at sbt.BuiltinCommands$.$anonfun$loadProjectImpl$2(Main.scala:914)
	at sbt.Command$.$anonfun$applyEffect$4(Command.scala:150)
	at sbt.Command$.$anonfun$applyEffect$2(Command.scala:145)
	at sbt.Command$.process(Command.scala:189)
	at sbt.MainLoop$.$anonfun$processCommand$5(MainLoop.scala:245)
	at scala.Option.getOrElse(Option.scala:189)
	at sbt.MainLoop$.process$1(MainLoop.scala:245)
	at sbt.MainLoop$.processCommand(MainLoop.scala:278)
	at sbt.MainLoop$.$anonfun$next$5(MainLoop.scala:163)
	at sbt.State$StateOpsImpl$.runCmd$1(State.scala:289)
	at sbt.State$StateOpsImpl$.process$extension(State.scala:325)
	at sbt.MainLoop$.$anonfun$next$4(MainLoop.scala:163)
	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
	at sbt.MainLoop$.next(MainLoop.scala:163)
	at sbt.MainLoop$.run(MainLoop.scala:144)
	at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:119)
	at sbt.io.Using.apply(Using.scala:27)
	at sbt.MainLoop$.runWithNewLog(MainLoop.scala:112)
	at sbt.MainLoop$.runAndClearLast(MainLoop.scala:66)
	at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:51)
	at sbt.MainLoop$.runLogged(MainLoop.scala:42)
	at sbt.StandardMain$.runManaged(Main.scala:223)
	at sbt.xMain$.$anonfun$run$11(Main.scala:133)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
	at scala.Console$.withIn(Console.scala:230)
	at sbt.internal.util.Terminal$.withIn(Terminal.scala:578)
	at sbt.internal.util.Terminal$.$anonfun$withStreams$1(Terminal.scala:358)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
	at scala.Console$.withOut(Console.scala:167)
	at sbt.internal.util.Terminal$.$anonfun$withOut$2(Terminal.scala:568)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
	at scala.Console$.withErr(Console.scala:196)
	at sbt.internal.util.Terminal$.withOut(Terminal.scala:568)
	at sbt.internal.util.Terminal$.withStreams(Terminal.scala:358)
	at sbt.xMain$.withStreams$1(Main.scala:87)
	at sbt.xMain$.run(Main.scala:121)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at sbt.internal.XMainConfiguration.run(XMainConfiguration.java:57)
	at sbt.xMain.run(Main.scala:46)
	at xsbt.boot.Launch$.$anonfun$run$1(Launch.scala:149)
	at xsbt.boot.Launch$.withContextLoader(Launch.scala:176)
	at xsbt.boot.Launch$.run(Launch.scala:149)
	at xsbt.boot.Launch$.$anonfun$apply$1(Launch.scala:44)
	at xsbt.boot.Launch$.launch(Launch.scala:159)
	at xsbt.boot.Launch$.apply(Launch.scala:44)
	at xsbt.boot.Launch$.apply(Launch.scala:21)
	at xsbt.boot.Boot$.runImpl(Boot.scala:78)
	at xsbt.boot.Boot$.run(Boot.scala:73)
	at xsbt.boot.Boot$.main(Boot.scala:21)
	at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.ExceptionInInitializerError: Exception scala.reflect.internal.FatalError:
  bad constant pool index: 0 at pos: 48461
     while compiling: <no file>
        during phase: globalPhase=<no phase>, enteringPhase=<some phase>
     library version: version 2.12.17
    compiler version: version 2.12.17
  reconstructed args: -classpath /Users/ar/.sbt/boot/scala-2.12.17/lib/scala-library.jar -Yrangepos

  last tree to typer: EmptyTree
       tree position: <unknown>
            tree tpe: <notype>
              symbol: null
           call site: <none> in <none>

== Source file context for tree position ==

 [in thread "sbt-parser-init-thread"]
	at scala.reflect.internal.Reporting.abort(Reporting.scala:69)
	at scala.reflect.internal.Reporting.abort$(Reporting.scala:65)
	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:28)
	at scala.tools.nsc.symtab.classfile.ClassfileParser$ConstantPool.errorBadIndex(ClassfileParser.scala:385)
	at scala.tools.nsc.symtab.classfile.ClassfileParser$ConstantPool.getExternalName(ClassfileParser.scala:249)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.readParamNames$1(ClassfileParser.scala:828)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.parseAttribute$1(ClassfileParser.scala:834)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.$anonfun$parseAttributes$7(ClassfileParser.scala:908)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.parseAttributes(ClassfileParser.scala:908)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.parseMethod(ClassfileParser.scala:611)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.$anonfun$parseClass$4(ClassfileParser.scala:534)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.parseClass(ClassfileParser.scala:534)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.$anonfun$parse$2(ClassfileParser.scala:160)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.$anonfun$parse$1(ClassfileParser.scala:146)
	at scala.tools.nsc.symtab.classfile.ClassfileParser.parse(ClassfileParser.scala:129)
	at scala.tools.nsc.symtab.SymbolLoaders$ClassfileLoader.doComplete(SymbolLoaders.scala:343)
	at scala.tools.nsc.symtab.SymbolLoaders$SymbolLoader.complete(SymbolLoaders.scala:250)
	at scala.reflect.internal.Symbols$Symbol.completeInfo(Symbols.scala:1542)
	at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1514)
	at scala.reflect.internal.Definitions.scala$reflect$internal$Definitions$$enterNewMethod(Definitions.scala:49)
	at scala.reflect.internal.Definitions$DefinitionsClass.String_$plus$lzycompute(Definitions.scala:1134)
	at scala.reflect.internal.Definitions$DefinitionsClass.String_$plus(Definitions.scala:1134)
	at scala.reflect.internal.Definitions$DefinitionsClass.syntheticCoreMethods$lzycompute(Definitions.scala:1438)
	at scala.reflect.internal.Definitions$DefinitionsClass.syntheticCoreMethods(Definitions.scala:1420)
	at scala.reflect.internal.Definitions$DefinitionsClass.symbolsNotPresentInBytecode$lzycompute(Definitions.scala:1450)
	at scala.reflect.internal.Definitions$DefinitionsClass.symbolsNotPresentInBytecode(Definitions.scala:1450)
	at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1506)
	at scala.tools.nsc.Global$Run.<init>(Global.scala:1214)
	at sbt.internal.parser.SbtParser$.<init>(SbtParser.scala:141)
	at sbt.internal.parser.SbtParser$.<clinit>(SbtParser.scala)
	at sbt.internal.parser.SbtParserInit$$anon$2.run(SbtParser.scala:191)
[error] java.lang.NoClassDefFoundError: Could not initialize class sbt.internal.parser.SbtParser$
[error] Use 'last' for the full log.
[warn] Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r)

scala-cli compilation failled

Sorry, not a Scala programmer.

% scala-cli package . -o shexs -f
[warn] ./src/main/scala/scala-cli-conf.scala:25:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "org.scalacheck::scalacheck:1.15.4"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:24:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "com.typesafe:config:1.4.2"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:20:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "org.typelevel::cats-effect-std:3.3.11"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:19:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "org.typelevel::cats-effect:3.3.11"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:18:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "org.slf4j:slf4j-simple:1.7.3"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:17:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "org.slf4j:slf4j-api:1.7.3"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:16:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "org.http4s::http4s-circe::1.0.0-M31"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:15:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "org.http4s::http4s-ember-client::1.0.0-M31"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:14:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "org.apache.jena:jena-shex:4.3.2"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:12:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "es.weso::shexsjena::0.2.0"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:11:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "es.weso::shapemap::0.2.2"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:10:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "es.weso::shapepath::0.2.2"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:9:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "es.weso::wikibaserdf::0.2.2"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:8:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "es.weso::shextest::0.2.2"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:7:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "es.weso::rbe::0.2.2"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:6:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "es.weso::wshex::0.2.2"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:5:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "es.weso::depgraphs::0.2.2"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:4:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "es.weso::shex::0.2.2"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^
[warn] ./src/main/scala/scala-cli-conf.scala:2:11
[warn] Using 'lib' is deprecated, use 'dep' instead
[warn] //> using lib "com.monovore::decline-effect::2.2.0"
[warn]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Compiling project (Scala 3.1.1, JVM (21))
Error: 21 is not a valid choice for -release
  scalac -help  gives more information
Error compiling project (Scala 3.1.1, JVM (21))
[hint] ./src/main/scala/scala-cli-conf.scala:2:16
[hint] "decline-effect is outdated, update to 2.4.1"
[hint]      decline-effect 2.2.0 -> com.monovore::decline-effect::2.4.1
[hint] //> using lib "com.monovore::decline-effect::2.2.0"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:4:16
[hint] "shex is outdated, update to 0.2.33"
[hint]      shex 0.2.2 -> es.weso::shex::0.2.33
[hint] //> using lib "es.weso::shex::0.2.2"
[hint]                ^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:5:16
[hint] "depgraphs is outdated, update to 0.2.33"
[hint]      depgraphs 0.2.2 -> es.weso::depgraphs::0.2.33
[hint] //> using lib "es.weso::depgraphs::0.2.2"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:6:16
[hint] "wshex is outdated, update to 0.2.33"
[hint]      wshex 0.2.2 -> es.weso::wshex::0.2.33
[hint] //> using lib "es.weso::wshex::0.2.2"
[hint]                ^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:7:16
[hint] "rbe is outdated, update to 0.2.33"
[hint]      rbe 0.2.2 -> es.weso::rbe::0.2.33
[hint] //> using lib "es.weso::rbe::0.2.2"
[hint]                ^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:8:16
[hint] "shextest is outdated, update to 0.2.33"
[hint]      shextest 0.2.2 -> es.weso::shextest::0.2.33
[hint] //> using lib "es.weso::shextest::0.2.2"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:9:16
[hint] "wikibaserdf is outdated, update to 0.2.33"
[hint]      wikibaserdf 0.2.2 -> es.weso::wikibaserdf::0.2.33
[hint] //> using lib "es.weso::wikibaserdf::0.2.2"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:10:16
[hint] "shapepath is outdated, update to 0.2.33"
[hint]      shapepath 0.2.2 -> es.weso::shapepath::0.2.33
[hint] //> using lib "es.weso::shapepath::0.2.2"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:11:16
[hint] "shapemap is outdated, update to 0.2.33"
[hint]      shapemap 0.2.2 -> es.weso::shapemap::0.2.33
[hint] //> using lib "es.weso::shapemap::0.2.2"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:12:16
[hint] "shexsjena is outdated, update to 0.2.33"
[hint]      shexsjena 0.2.0 -> es.weso::shexsjena::0.2.33
[hint] //> using lib "es.weso::shexsjena::0.2.0"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:14:16
[hint] "jena-shex is outdated, update to 5.0.0"
[hint]      jena-shex 4.3.2 -> org.apache.jena:jena-shex:5.0.0
[hint] //> using lib "org.apache.jena:jena-shex:4.3.2"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:17:16
[hint] "slf4j-api is outdated, update to 2.0.13"
[hint]      slf4j-api 1.7.3 -> org.slf4j:slf4j-api:2.0.13
[hint] //> using lib "org.slf4j:slf4j-api:1.7.3"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:18:16
[hint] "slf4j-simple is outdated, update to 2.0.13"
[hint]      slf4j-simple 1.7.3 -> org.slf4j:slf4j-simple:2.0.13
[hint] //> using lib "org.slf4j:slf4j-simple:1.7.3"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:19:16
[hint] "cats-effect is outdated, update to 3.5.4"
[hint]      cats-effect 3.3.11 -> org.typelevel::cats-effect:3.5.4
[hint] //> using lib "org.typelevel::cats-effect:3.3.11"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:20:16
[hint] "cats-effect-std is outdated, update to 3.5.4"
[hint]      cats-effect-std 3.3.11 -> org.typelevel::cats-effect-std:3.5.4
[hint] //> using lib "org.typelevel::cats-effect-std:3.3.11"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:24:16
[hint] "config is outdated, update to 1.4.3"
[hint]      config 1.4.2 -> com.typesafe:config:1.4.3
[hint] //> using lib "com.typesafe:config:1.4.2"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^^
[hint] ./src/main/scala/scala-cli-conf.scala:25:16
[hint] "scalacheck is outdated, update to 1.18.0"
[hint]      scalacheck 1.15.4 -> org.scalacheck::scalacheck:1.18.0
[hint] //> using lib "org.scalacheck::scalacheck:1.15.4"
[hint]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Compilation failed

Start using a logging library

As seen in #232, this library has print statements used for debugging. However, when the library is used as an external dependency of a parent application, those print statements interfere with the console output of the application and appear in the command line.

I think we should use a specialized logging library in the future; e.g, Logback and scala-logging, to print information while making the library easy to integrate in bigger projects.

Make ShExR shex:shapes be an RDF Container

We are planning to replace shex:shapes to be a container in ShExR representation so, instead of:

[] a sx:Schema ;
  sx:shapes <S1>, <S2> .

we will have

[] a sx:Schema ;
  sx:shapes (<S1> <S2>) .

Refactor validator code

The validator code should be refactored to a new module which can be published independently from the rest.

Some reasons:

  • There may be some projects that only want to use the ShEx abstract syntax and don't depend on the validator
  • We may want to have different validators, so we should define an abstract class for validators with different implementations

Migrate to cats effect 3

Migrate to cats effect 3 and fs2 3

At this moment the only failing dependency is decline, but there is already an open issue and a PR supporting cats-effect 3.
Once it is published, we could do the full migration.

Adding a comment breaks parsing of a Shex file

Whenever I add a comment to a shape, the Shex fails to compile. For instance, this shape breaks the whole parsing:

:MyShape {
  obo:RO_0000081 IRI ; # Comment
}

with error:

line 1:1552 missing '}' at '<EOF>'
[info] - should validate against the Shex definition *** FAILED ***
[info]   Error at 1:1552 missing '}' at '<EOF>' (RDF4JMarshallerSpec.scala:88)

while

:MyShape {
  obo:RO_0000081 IRI ; 
}

compiles and works perfectly. It seems like the comment is commenting out the rest of the file till the end.

Could it be something related to the warning you can see when generating the code from the ANTLR file?

[error] warning(158): /Users/cebriant/forked_repos/shex-s/modules/shex/src/main/antlr4/ShExDoc.g4:599:62: fragment rule COMMENT contains an action or command which can never be executed

Support for Java 8

Hi @labra,

We are using this library for Map Reduce processing within Apache Spark and would like to execute some tests on AWS EMR. Unfortunately, their environment uses Java 1.8 and claims that this library was compiled with Java 1.11.

Exception: java.lang.UnsupportedClassVersionError: es/weso/shex/parser/ShExDocLexer has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0.

Warnings in doc generation

Activating the scalac option -Xfatal-warnings which stops compilation when there is a warning works for the test and compilephases.

However, for scalaDocgeneration phase it fails because it seems that Antlr generates some code that doesn't pass ScalaDoc.

In order to publish the library, we deactivated the -Xfatal-warnings option, but it is a hack and it would be better to either repair the problem with Scaladoc generation warnings or deactivate that option only for the scalaDoc generation phase.

Repair stackoverflow when parsing manifest.ttl

The module shexTest contains code that parses the manifest.ttl of ShExTest but it raises a stack overflow.

I changed the stack memory by configuring the file .jvmopts but it doesn't seem to work.

Improve ShEx error messages

The information of error messages is incomprehensible for an end user. See this issue about SHaclEX.

Providing a better error information system for ShEx can be a challenge given ShEx expressivity that can make it difficult to guess which is the root cause of the error. However, for some (most) of the shapes, it should be easier.

The strategy to improve this issue will probably involve several steps:

  • Refactor the library to separate the natural language messages from the error messages. Right now, the error messages are created from natural language messages by hand which is not very elegant. It would be much better to define an upper class for ShExError and define different sub-classes for the different cases. Later, we could try to re-generate the natural language representation of those classes. An added benefit is that we could even generate localized error messages in different languages. We have already started with this refactoring but it was left unfinished.

  • Identify classes of shapes features which can provide better error messages. For example, some shapes which have no repeated properties can provide more intuitive error messages. We also started this process by defining Flat shapes which are shapes that have no repeated properties. Error messages for these shapes could provide much more informative information.

This issue will be divided in several issues and remain open until we consider that the error messages are more comprehensible.

Replace dependency on Java's HttpClient by http4s client

I would prefer not to depend on Java's httpClient which depends itself on Java 1.11 and replace it by http4s client.
We used httpClient from java.net.http because it was handy and it allowed us to follow redirects. However, http4s Client also has middleware that supports redirects.

The code to change is in Deref.scala

Meta-issue

This issue will collect info about the project

We get an exception when another dependency upgrades Scalatest/Scalastic to 3.1.0

We are using shex with these dependencies (Scala 2.12) :

        "es.weso" %% "shex" % "0.1.52" % Test,
        "es.weso" %% "srdf4j" % "0.1.52" % Test,

in Scio pipelines that ingest triples in our databases. We were using com.spotify" %% "scio-test" % "0.8.0-beta2" % Test and all tests for test validation are green and passing but the moment we bump to com.spotify" %% "scio-test" % "0.8.0" % Test we get this exception in all test that are about validating Shex and that were working OK:

[info] - should validate simple examples *** FAILED ***
[info]   java.lang.NullPointerException:
[info]   at es.weso.rbe.interval.IntLimit.<init>(IntOrUnbounded.scala:110)
[info]   at es.weso.shex.validator.Table$CTable$.max2IntOrUnbounded(Table.scala:178)
[info]   at es.weso.shex.validator.Table$CTable$.mkTableAux(Table.scala:160)
[info]   at es.weso.shex.validator.Table$CTable$.$anonfun$mkTableAux$2(Table.scala:112)
[info]   at scala.util.Either.flatMap(Either.scala:341)
[info]   at es.weso.shex.validator.Table$CTable$.comb$1(Table.scala:110)
[info]   at es.weso.shex.validator.Table$CTable$.$anonfun$mkTableAux$5(Table.scala:116)
[info]   at scala.collection.LinearSeqOptimized.foldLeft(LinearSeqOptimized.scala:126)
[info]   at scala.collection.LinearSeqOptimized.foldLeft$(LinearSeqOptimized.scala:122)
[info]   at scala.collection.immutable.List.foldLeft(List.scala:89)

And looking at the offending code https://github.com/weso/shex-s/blob/master/modules/rbe/src/main/scala/es/weso/rbe/interval/IntOrUnbounded.scala#L110 it is in a function provided by scalastic that our dependency scio-test bumped from 3.0.8 to 3.1.0. So somehow that version bumping has a spurious interaction with the shex library but I weren't able to reproduce in downsized build.sbt (still trying).

Does this bug report rings any bell on you?

Generate ShEx-based subsets

Implement a ShEx based RDF data subset

There are 2 approaches:

  • Slurp RDF triples while validating, this is the approach followed by ShEx.js and PyShex
  • Focus only on creating ShEx based graph traversal subset which could be faster but could have issues with invalid RDF data

Rename ShapeLabel to Label

ShapeLabels can be BNode or IRIs and are used both to label ShapeExprs and TripleExpr. A better name would probably be Label

Repair "conflicting cross-version suffixes in ProjectRef"

sbt generates this ugly warning:

Modules were resolved with conflicting cross-version suffixes in ProjectRef...)
[error]    es.weso:rbe _2.12, _3
[error]    es.weso:wikibaserdf _2.12, _3
[error]    es.weso:shextest _2.12, _3
[error]    es.weso:shexsjena _2.12, _3
[error]    es.weso:wshex _2.12, _3
[error]    es.weso:shapepath _2.12, _3
[error]    es.weso:shex _2.12, _3
[error]    es.weso:depgraphs _2.12, _3
[error]    es.weso:shapemap _2.12, _3

I wonder how I can solve it....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.