Fork me on GitHub
#rdf
<
2022-05-15
>
Bart Kleijngeld09:05:44

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?

quoll13:05:43

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.

quoll13:05:46

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

quoll13:05:50

I definitely need to update the entity reader if I want to allow URIs as nodes :thinking_face:

Bart Kleijngeld08:05:52

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 Kleijngeld08:05:01

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)

quoll11:05:35

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 Kleijngeld11:05:38

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?

quoll11:05:55

URI objects

quoll11:05:33

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

quoll11:05:06

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 Kleijngeld11:05:57

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 Kleijngeld11:05:44

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

quoll12:05:39

Just keep talking over there. It's fine

👍 1
quoll13:05:26

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 Kleijngeld08:05:37

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 😄.