rdf

liebs 2024-08-14T17:19:53.747289Z

howdy, if I want to load RDF data into a Clojure app, what's the simplest approach? I would prefer Turtle or JSON-LD format.

Max 2024-08-14T22:14:13.244929Z

I asked https://clojurians.slack.com/archives/C09GHBXRC/p1691793693974709 a while back. For TTL, there’s https://github.com/quoll/raphael. JSON-LD is hard.

liebs 2024-08-14T22:22:59.321659Z

yeah I've basically given up on JSON-LD. It seemed promising but I think I'm going to settle for Turtle. I'll give raphael a go, thx.

Drew Verlee 2024-08-23T02:36:38.752859Z

Can you elaborate on what you mean by load?

Bart Kleijngeld 2024-09-02T14:28:22.868679Z

@bhlieberman93 @max.r.rothman I'd love to learn what you found hard about JSON-LD, or make it possibly not worth going for. I'm considering it as a more accessible way to create Linked Data without bothering devs to learn Semantic Web stuff, so your experiences could be of value to me.

quoll 2024-09-02T14:29:52.048559Z

@bartkl which library are you planning to use?

Max 2024-09-02T14:31:04.463819Z

Mostly https://clojurians.slack.com/archives/C09GHBXRC/p1723722108402759?thread_ts=1723655993.747289&channel=C09GHBXRC&message_ts=1723722108.402759, I was using existing JSON-LD from a public ontology in that project

Bart Kleijngeld 2024-09-02T14:34:11.956439Z

I'm not currently at the stage where I'm actually considering specific libraries. JSON-LD from a more architectural/organisational level seems promising to enrich existing APIs to become semantically meaningful to machines (LD). I guess I interpreted the critical remarks here as applying generally to JSON-LD, but probably it was meant (in context) wrt parsing as @max.r.rothman clarified. (Not trying to hijack this thread, sorry)

Max 2024-09-02T14:46:07.678159Z

Yeah exactly. Something you’ll want to consider in that architectural decision is the lack of tooling support for json-ld in the Clojure ecosystem

Bart Kleijngeld 2024-09-02T14:46:39.255989Z

That's good to know. Thanks!

liebs 2024-09-02T17:05:41.676779Z

@bartkl I am also pretty new to the RDF zone so definitely take that under advisement. But essentially I had a similar experience to Max. My initial encounter with JSON-LD was through Fluree, which I was evaluating for usage in a personal project for interacting with DBPedia. However, Fluree's JSON-LD parser did not work with the DBPedia data, which was not a roadblock I encountered elsewhere (I am also looking at RDF tooling in OCaml.) I came to this channel and various people mentioned Java libs for JSON-LD, but in spite of my relative confidence using Java interop, I thought the libraries looked a little too complicated for my use case. So I've opted to stick with TTL, because I have a basic grasp of how to use it already (and the library support is more robust).

quoll 2024-09-02T17:10:13.484689Z

Hmmm, this sounds like an opportunity. Either creating a new JSON-LD parser, or fixing the one from Fluree. @bhlieberman93, was it the complete DBPedia download? Did it fail completely, or did it load but with errors?

liebs 2024-09-02T17:13:07.527229Z

I'd have to retrace my steps and get back to the errors I was seeing, but it didn't load. I recall having to modify the shape of the JSON in order for it to fit to the schema specified by Fluree, but that also did not work. I have some free time today, so I can look into what I was seeing. @quoll

simongray 2024-08-15T08:53:39.357009Z

There's also Aristotle (Apache Jena) if you want an entire RDF solution around it.

quoll 2024-08-15T11:41:48.402759Z

I’ve used Java libs for JSON-LD, but haven’t liked them. Fluree suggested theirs, and I’ve meant to look at that code. I did consider doing it myself, but it’s kind of painful, especially since the context is stack based (not so hard, but fiddly) and you can import other files into the context at any time (that’s the trickier part). I figured it was better to use Fluree’s

quoll 2024-08-15T11:43:12.824319Z

Please let me know if there are any problems with Raphael! It works for me in the places I’ve employed it, but I’m always happy to tweak it if anything shows up that isn’t quite right for you

liebs 2024-08-15T12:30:22.460879Z

I looked at Jena initially but I was running into dependency conflicts unfortunately. I will check out Raphael and see what's to see, thanks @quoll!

liebs 2024-08-26T23:19:44.645599Z

I am playing around with grabbing some Turtle files off the web and loading them into memory for exploratory purposes. Possibly graphviz, etc. @drewverlee

quoll 2024-08-26T23:46:25.018869Z

Raphael would probably be the way to go then. It’s very light on dependencies (they’re both things I’ve written which aren’t dependent on anything else).

quoll 2024-08-26T23:54:14.772009Z

It creates a map containing the base, namespace mappings and a seq of triples, which are just 3-element vectors. By default, the 3 elements are IRIs, blank-nodes, and typed literals, as defined by the RuDolF library (one of the 2 dependencies), though the typed literals are replaced by doubles, longs, strings and java.util.Dates when those types are recognized. So it’s usually easy to work with. If you want different behavior, that’s straightforward, since the element generation is handled by a protocol (with a default that I just described), and triples themselves are also handled by a protocol, so you can generate something other than vectors that accumulate in a seq.