Add support for link types

This doesn’t allow inline typed links but allows us to say something about the note itself. It seems like an excellent start for me :).

On the practical side, I would go with double brackets, so we can still use auto-complete.

I also dream about having the possibility of using entities as properties. But I don’t think that front matter allows this.

Would that be something nice to have?

---
title: awesome recipe
[[has ingredients]]: [[ingredient1]], [[ingredient2]]
[[preparation time]]: 5 minutes
---
3 Likes

Double brackets makes sense, but I think licat mentioned that it’s currently not recognized as a link.

And using entities as properties maybe sounds a bit confusing: It’d be both a node in the graph and an edge. And not so sure what the use would be for this? As long as you can query all has ingredients relations.

True, it’s not recognized.
You cannot ctrl+link inside the note :’(

I was thinking about describing the properties themselves, which is useful when your Personal Wiki is a mix of Wiki and Database.

But now that you say it, it’s confusing. Also, Front matter is already defined as YAML or TOML. (do they allow double brackets [[ ]] ?)

For now, to describe complicated stuff inside my notes,
like formulas, graphs, multi-arrays, whatever.

I’ll write:

` ``yourPreferedDialectToDescribeThings

The contents

` ``

And then have scripts or plugins to extract and consume such data. That would do in the meantime, I guess

1 Like

It is worth looking at Neo4j. They created a cypher query language that allows you to have relationship types. The syntax if pretty straight forward too.
(:person) --[:works for]–>(:company)
(:person) --[:owns]–>(:car)

3 Likes

This might be even better

What is Aspen?
Aspen is like Markdown but for graph data.

  • Nobody

Aspen is a simple markup language for creating graph data.

Aspen lets you write about people, places, things, and the relationships between them using marked-up text, and converts your text to valid Cypher that can be used in Neo4j graph databases.

So, Aspen is both a markup language and a software tool that converts text to Cypher.

Aspen does not aspire to be a query language—Cypher is a truly elegant language for querying graph data, and we’re frankly in awe of it. Aspen is intended to make it easy to write graph data by hand.

3 Likes

Proposed solution using existing syntax for adding metadata/attributes to markdown elements, including links:
(I would prefer extension to YAML or at least JSON)

---
id: NoteMe
title: king Me
aliases: [little king, small king]
---
# king Me
King Me had three children: 
- [Alice](noteA){link-type: parent-child}
- [Bob](NoteB){link-type: parent-child, probability: 1}
- [Charlie](NoteC){id: LinkID123, link-type: parent-child, probability: 0.5, paired-link: "C#LinkID124"}

Links would be understood as links between current note/node(subject) and link-target(object).
In the future they could be queried/analyzed/visualized using e.g. Neo4J/Cypher. (Either externally or in Obsidian if it gets integrated with Neo4j/Cypher.)

Initially, link type can be specified by syntax used to assign class ("." prefix), we can even specify multiple relationship types in one link: “[Alice](NoteA){.parent-child .loves}”. This might cause collision with other uses of classes so there could be dedicated syntactic-sugar for link-type (":" prefix) just like already existing for id ("#" prefix) or for class ("." prefix). Then we would have:

...
# king Me
King Me had three children: 
- [Alice](NoteA){:parent-child :loves}
- [Bob](NoteB){:parent-child, probability: 1}
- [Charlie](NoteC){#LinkID123 :parent-child, probability: 0.5, paired-link: "C#LinkID124", updated: 2020-11-24}

The metadata could be assigned to inline links manually or automatically (either permanently or temporarily) by Natural-Language-Processing of surrounding text, e.g. using Aspen.

Except [syntactic-sugar for link-type] which resembles Cypher, this would not clutter the world by any new syntax while allowing full, extensible functionality.

Edit 2020-12-29: Idea to mark link type by colon prefix might be incompatible with marking link-states in css https://www.w3schools.com/css/css_link.asp so we might need to live only with classes and key-value pairs. I do not understand enough CSS yet to determine this.

1 Like

Workarounds:
In YAML, [[name without comma or colon or brackets]] is an array containing only one element, which happens to be a again an array containing only one string “name without ... or brackets”. We could interpret YAML/JSON substructure with such properties as a link to innermost string but that would be implicit, not explicit.


Option: We can enclose each link in YAML in quotation marks to store it as quoted string "[[link]]" or '[[link]]'. Some characters like # and other need to be escaped in these.

Option: AFAIK, we can use YAML block scalar to store any text without need to escape anything.
Just introduce multiline string by pipe character and put the content on the next line. Indent the content more than the line above (by spaces, not tabs).

key: |
  # headings, 
  [[links]], #tags, {}
  C:\paths with\backslashes\
  etc
  can be used in multiline string (YAML block scalar)
  It starts on next line after pipe character indicator. 
  Just indent each line of string by more spaces than the line above string. 

Links in front-matter were also discussed in Include / show note links in yaml frontmatter (v0.8.5)

Strings stored in YAML would then need to be parsed as markdown
Alternatively, and then parse strings within parsed yaml as markdown (both, keys and values) to see if they match wiki-link syntax.


Option: we could specify custom data type before each link or hypertext. Possible results:

  • !link [[my link]]
  • !link "[[my link]]"
  • !link "my link"
  • !md "hypertext with [[my link]]."
1 Like

Otherwise, there are several serialization formats for linked data.
N-Triples” follows structure of sentence: "subject predicate object. " where each element is usually autolink to corresponding URL, i.e. url enclosed in angle brackets “< >”. There is no reason to disallow other syntax for links.
So any sentence in markdown matching the pattern of three consecutive links could be interpreted as typed link and converted e.g. to Cypher.
For example sencence “[[link1]] [link 2](link2) <http://example.com/link3>.” would become (link1)--[link2]-->(http://example.com/link3) in Cypher.

Turtle syntax” allows to express multiple relations together more concisely by extending N-triples sentence format to nested structure similar to YAML.


Aspen is not restricted to one syntax but can easily understand any syntax proposed i this thread, according to:

This topic is most interesting topic in forum. And will lead us to another project. A markup format which can be querriable by sparql or cypher. Thats the future of text

1 Like

There are several amazing ideas of how to express this knowledge. I wonder if it’s better to just embrace all these possibilities.

Some ‘dialects’ are super expressive, but also more complicated. Different tools for different tasks.

The good thing is that Markdown allows us to add code segments, where we can add whatever we want.


` ``triples

Here some triples

`` `

` ``cypher

And also some cypher

` ``

Perhaps the best would be to experiment with these, and use plugins that can extract and process the different ‘dialects’, depending on the task.

3 Likes

I’ve been working on a converter of Obisidian vaults to Cypher: Semantic Markdown converter: Visualize your Obsidian vault in Neo4j Bloom!

This allows you to define typed links as follows:
- linkType [[note 1]], [[note 2|alias]]

If people here are interested in different ways of specifying link types, let me know and I can implement it! (If it’s not too complicated :))

3 Likes

@Emile Is it feasible to support user-defined specification (syntax/grammar) of typed links as in the short demo of Aspen linked above↑? (e.g. duplicate or cooperate) (Edit: Thank you for reply.)

I do not expect there to be one standardized syntax since basically everything stored in any vault can be interpreted as some graph (of connected neurons) where a relation might be also object or subject of another relation.

User might want to analyse already existing notes with fixed syntax, visualize metadata of notes, another time to process relations hidden in natural language prose, produce one from the other, …
Having to request/implement every possible nuance would be nuisance for both users and especially for the developer.

Interesting. From a quick look, I’m worried how developed Aspen is. Development doesn’t seem to be very active, and it uses Ruby, so I’m not sure how easy it is to integrate. And I’m not sure how it works with multiple files.

A user-defined specification might be very nice, though, especially if people want to add properties to links, or if people consider different things than different note files as nodes, as you mention. Lots of options!

Hello Malecjan,

I think one can embed a graph in our notes using snippets


## This is my typical Note

It contains contents in standard Markdown and also snippets with graphs:

```Aspen
default Person, name
default_attribute Employer, company_name
reciprocal knows, is friends with

# Write out the narrative data
(Matt) [is friends with] (Brianna).
(Eliza) [knows] (Brianna).
(Matt) [is friends with] (Eliza).

(Matt) [works for] (Employer, UMass Boston).
\```

More content..

Then we can implement a processor of ‘graph snippets’. Implementation wise, for Aspen, I think this is to invoke their library to generate the corresponding Cypher…

… If we need the cipher we can process the markdown to extract it, or possibly other format. One could even have a universal graph model that helps to go from one format to another.

What uses do you foresee of Aspen? or Turtle embedded in markdown? (I’m curious :slight_smile:

Oh, I see, Aspen it’s Ruby.

I’m kind of wondering too. Is this to use semantic links between notes? Or just to construct graphs in general?

The turtle syntax sounds a bit cumbersome, maybe? But at least it’s easy to implement :joy:

I’m pretty sure that Aspen or turtle would allow us to build a graph, embedded within the text of the markdown

In the same way, we put code in a Jupyter Notebook!. The concept is powerful…but I don’t have a use case right now :smiley:

I imagine that if one embeds structured data, one can write factual data, that can be extracted and procesed afterwards. Or you could query your vault, ask complex questions, or do faceted search.

Depends on the person, and what are they using their vault for I guess :slight_smile:

What things can be done with the Neo4J Bloom?

@cristian If (Subject)[predicate](object) is standard Aspen’s syntax then this is definitely an option.
I initially dismissed Aspen when looking on it’s page, as just another syntax to clutter the world. But the demo shows the better part of it.
I understand it as a way to integrate Obsidian / simple markdown files, editable by any custom tool, with powerful graph-database querying and analysis. It can interpret texts already formulated in any comprehensible syntax.

Using fenced code blocks to include another syntax in Obsidian files is very good idea IMHO, however If I enclosed everything relevant to block …

```Aspen
... ...
```

… Then I would likely enclose every file in a vault, including other code-blocks and YAML headers which Obsidian would not understand. I might also want to include relationships between files and directories.

If you mean to store code for Aspen in code block and then process data of whole vault based on that, then I do not have any caveat.

The things missing now:

  • Make cooperation with graph-database tools work out of the box via Obsidian plugin.
  • Apply it to whole vault or any selection of notes produced via filtering. The demo shows only application to content of single file.
  • Two-sided interaction, e.g. open note in Obsidian by clicking on corresponding node in Neo4j Bloom, automatically edit metadata (YAML header) of markdown file based on results from Neo4J analysis, or manually edit note e.g. in Obsidian and (instantly) update graph-database in neo4j.

Use cases: many shown in presentations of neo4j, with many built packages for analysis, but applied to bunch of existing personal files.
I do not know if Aspen and neo4j is the best option, I would just like to have such options/tools for knowledge/… management tool and Aspen and Emile’s toolbox go in that direction.

1 Like