On the possibility of labeling link types (or, org-roam notes as semantic web triples)

I’m wondering whether this kind of functionality is possible, and/or whether it might be integrated into org-roam.

The idea is to label links, so that links between notes can become subject → verb → object triples. Right now, if a note called “Tolkein” contains a link to another note, called “Lord of the Rings,” you can express that as a kind of sentence:

<Tolkien> <linksTo> <Lord of the Rings> . 

But what would be really neat is to be able to specify what the really means. In this case, it’s a verb like , so that would be:

<Tolkien> <wrote> <Lord of the Rings>

My own solution to this, which I use in my personal Zettelkasten, is just to have notes for verbs, and link out to the verbs, as well. So a verb note would look like:

#+title: wrote
#+roam_tags: verb

For when a writer writes a creative work.
Example: T.S. Eliot wrote The Waste Land

which would then mean I could write:

#+title: Tolkien
#+roam_tags: person

 - [[The Hobbit]]
 - [[Lord of the Rings]]

That’s cool, because then that’s basically structured data, like that on Wikidata, DBPedia, or some other graph database. Just written much easier. From there, one could write a little parser that would parse out that structure to:

<Tolkien> <wrote> <The Hobbit> . 
<Tolkien> <wrote> <Lord of the Rings> . 

That would allow you to then make all kinds of structured queries to your Zettelkasten. For instance, you could ask, who wrote The Hobbit? Or, what books in my collection were published in 1922?

What do people think?

Typed links have been discussed a fair bit on this forum, though I can’t find the thread I’m thinking of ATM. But @alan was working on this.

This is the post I made ages ago

I swear it’s on my list, I wanted to have a PR back in like February but this semester has been extremely unkind.

Oh awesome. That’s pretty close to what I was thinking. Just in reverse. So it would be [[Tolkien]] [[Lord of the Rings::wrote]] in that case. Looking forward to testing your PR.

I think this principle is often referred to as “Concept Map”: Concept map - Wikipedia

Would be interesting to include it in the graph, and make it possible to filter by relations to get visual representations of them. It makes me think of category theory. There’s definitely deep value not only in bits of information itself, but also the relationships between them. Building efficient tooling to highlight those relationships is probably worth exploring.

If you dig through the post replies I talk about this type of relation a bit, but I don’t think the syntax or concept design of org-roam makes it very practical or friendly. I break it down as forming the relation 'Tolkien wrote the Lord of the Rings in the context of current note'. To form the relationship directly you would need to be in a note for Tolkien and just write something like [[Lord of the Rings::written_by]] or vice versa. In the example you made the note would just have a link to Tolkien and then separately show up in a backlink buffer as if the current note was written by Lord of the Rings.

Managing a graphDB style (Tolkien)-[:wrote]->(Lord of the rings) relationship would be a different undertaking than what org-roam currently does.

Yes, sometimes it’s been useful to me to have labeled link types, usually when I’m trying to make sense of a new research area and am literally drawing a concept map.

Welcome to the community @jonathan! Great idea :slight_smile:

When I first heard about @alan’s post from last year, and went and tried to digest it, I have to admit, the discussion went a bit deeper than I was following…

But it did inspire me to play around a little bit. I created a minimal working example of the concept to satisfy my curiosity. The before graph, with normal unlabeled edges:

And a version with some verbs as edge labels:

I should note, that the arrows are going different directions because between the first image and the second, I learned how to add a property to the edges in the graph that flipped them, and gave them the direction that seems most correct to me.

IMHO, ideally the labels would be written above and parallel to the edges, but I couldn’t figure out how to do that, or if it were possible to do using dot.

I may be mistaken, but my hunch is that the simplest implementation that could produce graphs like the above is:

a) determine what link description delimiter separates the verb from the object node’s name (:: seems fine)
b) add a label field to the properties column when updating that link into the database
c) write that label property out along with that edge when generating the dot file

Would that seem like a reasonable place to start, as far as this feature goes? Would anything else be necessary?

BTW my personal preference would be to put the verb prior to the object, so that we are able to use the active voice and normal English word order most of the time.

1 Like