rdf

Bart Kleijngeld 2022-05-15T09:06:44.725979Z

I've succeeded in loading my RDF triples into Asami, but I can't get the entity function to work with nested? set to true. My triples (examples for demonstration: everything is a string):

(take 2 rdf-data)

;; Output

([""
  ""
  "\"1\"^^<>"]
 [""
  ""
  ""])
Then I add them to the store:
@(d/transact conn {:tx-triples model})
Then, I'm trying to use entity to retrieve some object (nested):
(d/entity (d/db conn) "" true)

;; Output:

{"" "",
 "" "_:e0047c979d3f4f7ebe4d980b2fd52b7293",
 "" ""}
As you can see, the blank node _:e0047c979d3f4f7ebe4d980b2fd52b7293 is not resolved. However, I know it's there:
(d/entity (d/db conn) "_:e0047c979d3f4f7ebe4d980b2fd52b7293" true)

;; Output:

{"" "\"1\"^^<>",
 "" "\"0\"^^<>",
 "" "",
 "" ""}
Am I doing something wrong or misunderstanding something? Is there something I can do to achieve this?

quoll 2022-05-15T13:16:43.708129Z

I'm thinking that it's because EVERYTHING is a string. I turned off type checking so that strings could be in any position in a triple, but the entity loading code was written before that. It sees a string and presumes that's a leaf.

quoll 2022-05-15T13:17:46.046689Z

Are you able to control the datatypes you're generating? I think you need to generate a node if you want to recurse into something

quoll 2022-05-15T13:18:50.649869Z

I definitely need to update the entity reader if I want to allow URIs as nodes ๐Ÿค”

Bart Kleijngeld 2022-05-16T08:49:52.245309Z

I can imagine allowing URIs as nodes is something that doesn't necessarily fit in with your vision for the project, and requires some mulling over. Is it an option then, to, in the meantime, override the default reader, as is demonstrated in the README:

;; nodes can also be read from a string, with the appropriate reader
=> (set! *data-readers* graph/node-reader)
=> (d/entity db #a/n "4")
Not sure if I'm understanding that correctly, I'm a beginner ๐Ÿ™‚. To respond to your other question and suggestion: I'm reading RDF Turtle files locally and can transform the data to my pleasing before putting it into Asami. So I'm in full control over the data types and shape. If you say generating nodes manually is an easier or better route, I'm willing to take it. I'm not sure exactly how I would do this though. Would you then generate a node for every IRI in the subject position of the triple, and keep a hash map of these associations so when you encounter that IRI in an object position of triples, you can replace it by a reference to the associated node?

Bart Kleijngeld 2022-05-16T08:52:01.613919Z

It is of course possible that Asami isn't the best fit for working with RDF data this directly. But I really love Asami and it solves a lot of issues for us (structural loop detection, recursive entity fetching, and native Clojure query DSL among other things)

quoll 2022-05-16T11:02:35.463819Z

Well, it was inspired by a couple of things. It's an index/store that is built for RDF, but I added the entity code based on Datomic. It shouldn't be too badโ€ฆ right now the entity code asks if the node that was just loaded is an internal node or keyword. If so, it recurses. I can add a test for URIs that also appear in a subject position. That should work without issue. It just results in an extra index lookup for URIs that aren't subjects anywhere. I think that's fine

๐Ÿ‘ 2
Bart Kleijngeld 2022-05-16T11:10:38.755099Z

And I presume those URIs can be plain strings which are being parsed to check if they are URIs? Or does that have a performance penalty and must they be Java URI objects or some other variation?

quoll 2022-05-16T11:19:55.324509Z

URI objects

quoll 2022-05-16T11:22:33.878299Z

Because otherwise: โ€ข every string needs to be checked โ€ข URIs can be flexible, and it's too easy to mess it up. eg. โ€œname:Bartโ€ is a valid URI

quoll 2022-05-16T11:37:06.040169Z

Anyway... this the RDF channel. We should be talking about this in #asami (I've been responding using my phone, so I wasn't paying attention to where we were)

Bart Kleijngeld 2022-05-16T11:41:57.677859Z

Yes, that makes sense. And I wasn't aware of that channel, I've joined it now. You're right, let's continue over there.

Bart Kleijngeld 2022-05-16T11:55:44.058849Z

Should I copy/paste our conversation over there? Or what is the best way forward

quoll 2022-05-16T12:28:39.002419Z

Just keep talking over there. It's fine

๐Ÿ‘ 1
quoll 2022-05-15T13:20:26.502079Z

I can try to spend time online today, but right now Iโ€™m about to make pancakes for my kids (and coffee for me)

๐Ÿฅž 1
Bart Kleijngeld 2022-05-16T08:16:37.989259Z

That's really nice of you, I'm happy with the help I'm receiving from you (and others here)! And sounds like you have your priorities sorted out well ๐Ÿ˜„.