quick visualization of tags – notes using sublime, zettlekasten, gephi, and bash

So you take your notes following the Zettlekasten method, do you? One thought per card? Cool. I was never taught how to take good notes, and I still struggle with it. Rene Schallner’s zk-sublime  suits the way I like to work these days, in a text editor. I end up with a lovely folder filled with markdown notes that have internal links, tag searching, ‘friends’ searching… it’s great. As long as I’m using Sublime 3. (which is no chore).

Anyway, I was thinking to myself that it would be nice to feed the notes into a static site generator to make a nice online version that other folks could peruse. This would require converting all of the internal links to markdown links, and if I was using Jekyll etc, adding the right kind of metadata to every post. I cheated, and tried to use mdwiki, a no-longer-actively-maintained project that turns a folder into a site with the addition of a single html file (containing all of the necessary js and so on). I spent a lot of time on that; here’s a bash script that turns the directory listing of my note folder into an index.md that mdwiki can use:


#!/bin/bash
# A sample Bash script to turn the contents of a directory
# into a md file with filenames as md links


# put the directory contents into a file
echo "creating toc"
ls > index.md

# put the brackets around the line
echo "beginning line formatting"
sed -i '.bak' 's/^/[/' index.md
sed -i '.bak' 's/$/]/' index.md

# duplicate the line

sed -i '.bak' -E 's/^(.*)/\1\1/' index.md

# now to convert the SECOND [ and ] to ( )

sed -i '.bak' 's/\[/\(/2' index.md
sed -i '.bak' 's/\]/\)/2' index.md

# and this bit was the start of me trying to create a unique page for each
# tag, which eventually would end up listing all relevant
# note pages. I got the files made, at any rate; nothing in 'em yet.

grep tags *.md -R > tags.md

sed -i '.bak' 's/#/ /g' tags.md
sed -E 's/([0-9]+.)([A-Za-z ]+.)('md:tags:')//g' tags.md | tr ' ' '\n' > tags2.md
sed -i '.bak' '/^[[:space:]]*$/d' tags2.md
cat tags2.md | xargs touch
rm tags2.md
echo "done"

which was fine, but meh.

So I abandoned that, after so.many.hours. I started focusing on the tags instead, realizing that at least having a visualization of how my notes interconnect. Every note has ‘tags’ in the metadata, so a grepping we go:


grep tags *.md -R > tags.md
sed -E 's/([0-9]+.)([A-Za-z ]+.)('md:tags:')/"\1 \2"\,/g' tags.md > net.csv

This gives me two columns, a file name in quotations, and the relevant tags. I cheat and use find and replace in excel on the second column to replace spaces with semi-colons. This I can then open in gephi, selecting ‘adjacency’ and ‘semi-colon’ and boom. A nice visual depiction of how my notes inter-connect.

First part of the day: several hours. Second part: 30 minutes. Sigh.

 

 

%d bloggers like this:
close-alt close collapse comment ellipsis expand gallery heart lock menu next pinned previous reply search share star