@@ -4,16 +4,12 @@ import cats.implicits._
44import org .rogach .scallop ._
55import org .rogach .scallop .exceptions ._
66import com .typesafe .scalalogging ._
7- // import es.weso.rdf.PrefixMap
87import es .weso .rdf .jena .Endpoint
98import es .weso .rdf .nodes .IRI
10- // import es.weso.schemaInfer.SchemaInfer
119import es .weso .shaclex .repl .Repl
12- // import es.weso.shapeMaps.NodeSelector
1310import fs2 ._
1411
1512import scala .io .Source
16- // import es.weso.server._
1713import es .weso .schema ._
1814import es .weso .rdf .jena .RDFAsJenaModel
1915import scala .concurrent .duration ._
@@ -27,6 +23,7 @@ import cats._
2723// import scala.concurrent.ExecutionContext
2824import fs2 .Pipe
2925import es .weso .rdf .RDFBuilder
26+ import es .weso .rdf .InferenceEngine
3027// import cats.implicits._
3128
3229object Main extends IOApp with LazyLogging {
@@ -115,6 +112,7 @@ object Main extends IOApp with LazyLogging {
115112 schema <- getSchema(opts, baseFolder, rdf)
116113 triggerName = opts.trigger.toOption.getOrElse(ValidationTrigger .default.name)
117114 shapeMapStr <- getShapeMapStr(opts, baseFolder)
115+ // _ <- IO { pprint.log(shapeMapStr) }
118116 pm <- rdf.getPrefixMap
119117 trigger <- fromEither(ValidationTrigger .findTrigger(triggerName, shapeMapStr, relativeBaseStr,
120118 opts.node.toOption, opts.shapeLabel.toOption,
@@ -230,16 +228,14 @@ object Main extends IOApp with LazyLogging {
230228 val path = baseFolder.resolve(opts.shapeMap())
231229 for {
232230 // TODO: Allow different shapeMap formats
233- content <- getContents(path.toFile.getName() )
231+ content <- getContents(path)
234232 } yield content.toString
235233 } else " " .pure[IO ]
236234 }
237235
238236
239237 // TODO: Move to a common tools package
240- private def getContents (fileName : String ): IO [CharSequence ] = {
241- val path = Paths .get(fileName)
242- // implicit val cs = IO.contextShift(ExecutionContext.global)
238+ private def getContents (path : Path ): IO [CharSequence ] = {
243239 val decoder : Pipe [IO ,Byte ,String ] = fs2.text.utf8Decode
244240 Stream .resource(Blocker [IO ]).flatMap(blocker =>
245241 fs2.io.file.readAll[IO ](path, blocker,4096 ).through(decoder)
@@ -266,8 +262,11 @@ object Main extends IOApp with LazyLogging {
266262 } else {
267263 IO (RDFAsJenaModel .fromURI(opts.dataurl(), opts.dataFormat(), relativeBase))
268264 }
269- newRdf = if (opts.inference.isDefined) rdf.evalMap(rdf => rdf.applyInference(opts.inference()))
270- else rdf
265+ newRdf = if (opts.inference.isDefined) for {
266+ inference <- Resource .liftF(fromEither(InferenceEngine .fromString(opts.inference())))
267+ r <- rdf.evalMap(rdf => rdf.applyInference(inference))
268+ } yield r
269+ else rdf
271270 } yield newRdf
272271 } else if (opts.endpoint.isDefined) {
273272 IO (Resource .liftF(Endpoint .fromString(opts.endpoint())))
0 commit comments