SRDFJena
SRDFJena
SRDFJena contains an implementation of SRDF based on Apache Jena models.
The RDFAsJenaModel
class implements the different interfaces.
Example usage
import es.weso.rdf.jena._
import es.weso.rdf.nodes._
import es.weso.rdf.triples._
val ex = IRI("http://example.org/")
// ex: IRI = IRI(http://example.org/)
val schema = IRI("http://schema.org/")
// schema: IRI = IRI(http://schema.org/)
val alice = ex + "alice"
// alice: IRI = IRI(http://example.org/alice)
val knows = schema + "bob"
// knows: IRI = IRI(http://schema.org/bob)
val bob = ex + "bob"
// bob: IRI = IRI(http://example.org/bob)
val t1 = RDFTriple(alice,knows,bob)
// t1: RDFTriple = RDFTriple(
// IRI(http://example.org/alice),
// IRI(http://schema.org/bob),
// IRI(http://example.org/bob)
// )
val showTriples = for {
emptyResource <- RDFAsJenaModel.empty
_ <- emptyResource.use(rdf => for {
newRdf <- rdf.addTriple(t1)
_ <- newRdf.serialize("TURTLE")
} yield ()
)
} yield ()
// showTriples: cats.effect.IO[Unit] = FlatMap(
// Delay(
// es.weso.rdf.jena.RDFAsJenaModel$$$Lambda$10738/0x0000000803a4e040@5ffac574
// ),
// <function1>
// )
import cats.effect.unsafe.implicits.global
showTriples.unsafeRunSync()