From 3e370d8cfa6b93c124ea253b798fed62abd4eb35 Mon Sep 17 00:00:00 2001 From: Jesse Wright <63333554+jeswr@users.noreply.github.com> Date: Sat, 23 Mar 2024 08:01:58 +0000 Subject: [PATCH] fix: patching https://github.com/weso/shaclex/issues/637 --- conversions/shacl2shex/Dockerfile | 9 +++++---- conversions/shacl2shex/{patch.scala => Shacl2ShEx.scala} | 4 ++-- package.json | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) rename conversions/shacl2shex/{patch.scala => Shacl2ShEx.scala} (98%) diff --git a/conversions/shacl2shex/Dockerfile b/conversions/shacl2shex/Dockerfile index 296009a..1f11588 100644 --- a/conversions/shacl2shex/Dockerfile +++ b/conversions/shacl2shex/Dockerfile @@ -1,10 +1,11 @@ FROM sbtscala/scala-sbt:eclipse-temurin-17.0.4_1.7.1_3.2.0 - - - + RUN git clone --depth 1 --branch v0.2.2 https://github.com/weso/shaclex WORKDIR /root/shaclex -COPY ./patch.scala ./modules/converter/src/main/scala/es/weso/shacl/converter/Shacl2ShEx.scala +# Workaround for https://github.com/weso/shaclex/issues/637 +RUN sed -i '207s/.*/ok(Some(components.collect { case shacl.MinCount(m) => m }.headOption.getOrElse(0)))/' ./modules/converter/src/main/scala/es/weso/shacl/converter/Shacl2ShEx.scala +RUN sed -i '211s/.*/ok(Some(components.collect { case shacl.MaxCount(m) => shex.IntMax(m) }.headOption.getOrElse(shex.Star)))/' ./modules/converter/src/main/scala/es/weso/shacl/converter/Shacl2ShEx.scala +COPY ./Shacl2ShEx.scala ./modules/converter/src/main/scala/es/weso/shacl/converter/Shacl2ShEx.scala RUN sbt compile CMD [ "sbt", "run --schema /shape.ttl \ --schemaFormat Turtle \ diff --git a/conversions/shacl2shex/patch.scala b/conversions/shacl2shex/Shacl2ShEx.scala similarity index 98% rename from conversions/shacl2shex/patch.scala rename to conversions/shacl2shex/Shacl2ShEx.scala index f9c5190..d3f4f8e 100644 --- a/conversions/shacl2shex/patch.scala +++ b/conversions/shacl2shex/Shacl2ShEx.scala @@ -204,11 +204,11 @@ object Shacl2ShEx extends LazyLogging { case class PredicateInverse(pred: IRI, inverse: Option[Boolean]) private def getMinComponent(components: List[shacl.Component]): Result[Option[Int]] = { - ok(option(components.collect { case shacl.MinCount(m) => m }.headOption.getOrElse(0))) + ok(Some(components.collect { case shacl.MinCount(m) => m }.headOption.getOrElse(0))) } private def getMaxComponent(components: List[shacl.Component]): Result[Option[shex.Max]] = { - ok(option(components.collect { case shacl.MaxCount(m) => shex.IntMax(m) }.headOption.getOrElse(Infinity))) + ok(Some(components.collect { case shacl.MaxCount(m) => shex.IntMax(m) }.headOption.getOrElse(shex.Star))) } // TODO: Conversion of components like BlankNodeOrIRI is ignored by now diff --git a/package.json b/package.json index 8934699..3360479 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "shapes": "npm run shc2shex && npm run ldo" }, "author": "", - "license": "ISC", + "license": "MIT", "dependencies": { "@anthropic-ai/sdk": "^0.18.0", "@inquirer/prompts": "^4.3.0",