Creating Mind Maps in Racket
(require mind-map) | package: mind-map |
Use this collection to leverage a form of note-taking with indented lines. Here, a mind map is a text document where each line is an idea. Each idea may be indented to illustrate a composition of ideas.
Machine Learning |
To Evaluate |
ELKI |
TensorFlow |
https://www.tensorflow.org |
Desired approaches |
Supervised |
Reinforcement |
You cannot escape a line break to combine lines. This is deliberate, because this format is not meant for writing complete sentences or paragraphs.
A line supports a leading mix of tabs and spaces, but an indentation error will occur if a scope cannot be inferred for a line. The rules for indentation imitate Python’s, such that a line with a lower level of indentation is expected to have the same number of tabs and spaces as a prior line in the same implied scope. See exn:fail:mind-map:indent.
1 Mind Map Language
Write #lang mind-map at the top of the previous example. Save it as "example.rkt", then require it in a REPL. You will get a thoughts identifier bound to a list. That list represents the parse tree of a mind map.
> (require "example.rkt")
> thoughts
In DrRacket, you can render thoughts as a pict.
(thoughts->pict thoughts)
2 API
procedure
(read-thoughts in) → list?
in : input-port?
Any trailing or leading whitespace is trimmed from a line.
This assumes there is no leading #lang line.
If a line has an indentation error, read-thoughts will raise exn:fail:mind-map:indent.
procedure
(thoughts->digraph-data thoughts) →
list? list? thoughts : list?
An element of the vertex list is a pair. The car of the pair is a non-negative integer representing the vertex ID. The cdr of the pair is the string label for the vertex.
An element of the edge list is a pair of vertex IDs, such that the car’s vertex points to the cdr’s.
> (thoughts->digraph-data thoughts)
procedure
(thoughts->pict thoughts) → pict?
thoughts : list?
procedure
(in-thoughts thoughts) → sequence?
thoughts : list?
The values are as follows:
The vertex ID (see thoughts->digraph-data) of a vertex, or #f.
The string label of the vertex identified by value 1. If the first value is #f, then this value is also #f.
The vertex ID of another vertex. Never #f.
The string label of the vertex identified by value 3.
You interpret these values as a directed edge with vertex labels. The vertex identified by the first value points to the vertex identified by the third value. If the first two values are #f, that means no edges point to the vertex identified by the third value.
> (sequence->list (in-values-sequence (in-thoughts thoughts)))
struct
(struct exn:fail:mind-map:indent exn:fail (lineno))
lineno : exact-positive-integer?
lineno is one-based.
Consider the following document, where > represents a tab.
Trunk |
Branch |
Leaf |
Leaf |
> Branch |
Branch |
Leaf |
Caterpillar |
Branch |
The Branch with a leading tab raises an indentation error, because the transition from Leaf to Branch implies a change in scope, but there is no prior scope at Branch-level with the same leading whitespace.
The indentation error can be fixed by replacing the tab with a space, or by replacing one space with a tab in all indented lines.
3 raco mind-map
The mind-map collection includes a raco command of the same name. The command will parse text files given as command line arguments and save the rendered mind maps to SVG files. Currently, any failure results in exit code 1.
$ raco mind-map path/to/mind-map.rkt path/to/notes.txt |
As implied in the above command line, the input files do not have to be Racket modules. If the file starts with #lang mind-map, then it will be loaded as a Racket module. Otherwise it will be read as a plain text file using read-thoughts.
By default, the command will render the SVG documents in a mind-maps-out directory, relative to the command’s working directory. You can override this directory with --dest.
$ raco mind-map --dest other-dir ... |
The command will not overwrite any files unless forced. Set -f or --force to overwrite any conflicting files.
By default, the command will print its activity on STDOUT. Use --quiet or -q to suppress STDOUT messages.
Run raco mind-map -h to review these options.
4 Project Information
Source Code: https://github.com/zyrolasting/mind-map
Thanks to Hadi Moshayedi for use of the racket-graphviz package in thoughts->pict.