update on visualizing sw files

I had a bit more of a read of the DOT manual, and found a neater way to write my dot files. So, here is the new code.

Now, a couple of examples:

First, Fibonacci numbers, with some saved examples.
The sw:
|context> => |context: Fibonacci>

fib |0> => |1>
fib |1> => |1>

n-1 |*> #=> arithmetic(|_self>,|->,|1>)
n-2 |*> #=> arithmetic(|_self>,|->,|2>)
fib |*> #=> arithmetic( fib n-1 |_self>, |+>, fib n-2 |_self>)
fib-ratio |*> #=> arithmetic( fib |_self> , |/>, fib n-1 |_self> )

fib |2> => |2>
fib |3> => |3>
fib |4> => |5>
fib |5> => |8>
fib |6> => |13>
fib |7> => |21>
fib |8> => |34>
fib |9> => |55>
fib |10> => |89>
fib |11> => |144>
fib |12> => |233>
fib |13> => |377>
fib |14> => |610>
fib |15> => |987>
fib |16> => |1597>
fib |17> => |2584>
fib |18> => |4181>
fib |19> => |6765>
fib |20> => |10946>
fib |21> => |17711>
fib |22> => |28657>
fib |23> => |46368>
fib |24> => |75025>
fib |25> => |121393>
fib |26> => |196418>
fib |27> => |317811>
fib |28> => |514229>
fib |29> => |832040>
fib |30> => |1346269>
And the dot:
digraph g {
"context" -> "Fibonacci"
"0" -> "1" [label="fib",arrowhead=normal]
"1" -> "1" [label="fib",arrowhead=normal]
"*" -> "arithmetic(|_self>,|->,|1>)" [label="n-1",arrowhead=box]
"*" -> "arithmetic(|_self>,|->,|2>)" [label="n-2",arrowhead=box]
"*" -> "arithmetic( fib n-1 |_self>, |+>, fib n-2 |_self>)" [label="fib",arrowhead=box]
"*" -> "arithmetic( fib |_self> , |/>, fib n-1 |_self> )" [label="fib-ratio",arrowhead=box]
"2" -> "2" [label="fib",arrowhead=normal]
"3" -> "3" [label="fib",arrowhead=normal]
"4" -> "5" [label="fib",arrowhead=normal]
"5" -> "8" [label="fib",arrowhead=normal]
"6" -> "13" [label="fib",arrowhead=normal]
"7" -> "21" [label="fib",arrowhead=normal]
"8" -> "34" [label="fib",arrowhead=normal]
"9" -> "55" [label="fib",arrowhead=normal]
"10" -> "89" [label="fib",arrowhead=normal]
"11" -> "144" [label="fib",arrowhead=normal]
"12" -> "233" [label="fib",arrowhead=normal]
"13" -> "377" [label="fib",arrowhead=normal]
"14" -> "610" [label="fib",arrowhead=normal]
"15" -> "987" [label="fib",arrowhead=normal]
"16" -> "1597" [label="fib",arrowhead=normal]
"17" -> "2584" [label="fib",arrowhead=normal]
"18" -> "4181" [label="fib",arrowhead=normal]
"19" -> "6765" [label="fib",arrowhead=normal]
"20" -> "10946" [label="fib",arrowhead=normal]
"21" -> "17711" [label="fib",arrowhead=normal]
"22" -> "28657" [label="fib",arrowhead=normal]
"23" -> "46368" [label="fib",arrowhead=normal]
"24" -> "75025" [label="fib",arrowhead=normal]
"25" -> "121393" [label="fib",arrowhead=normal]
"26" -> "196418" [label="fib",arrowhead=normal]
"27" -> "317811" [label="fib",arrowhead=normal]
"28" -> "514229" [label="fib",arrowhead=normal]
"29" -> "832040" [label="fib",arrowhead=normal]
"30" -> "1346269" [label="fib",arrowhead=normal]
}
 
And now, some plurals:
|context> => |context: learning plurals>

source |context: learning plurals> => |url: http://www.macmillandictionary.com/thesaurus-category/british/irregular-plurals>

plural |word: *> #=> merge-labels(|_self> + |s>)

plural |word: calf> => |word: calves>
plural |word: child> => |word: children>
plural |word: corpus> => |word: corpora>
plural |word: elf> => |word: elves>
plural |word: foot> => |word: feet>
plural |word: goose> => |word: geese>
plural |word: genus> => |word: genera>
plural |word: half> => |word: halves>
plural |word: hoof> => |word: hooves>
plural |word: index> => |word: indices>
plural |word: knife> => |word: knives>
plural |word: leaf> => |word: leaves>
plural |word: life> => |word: lives>
plural |word: loaf> => |word: loaves>
plural |word: matrix> => |word: matrices>
plural |word: medium> => |word: media>
plural |word: man> => |word: men>
plural |word: mouse> => |word: mice>
plural |word: ovum> => |word: ova>
plural |word: ox> => |word: oxen>
plural |word: penny> => |word: pence>
plural |word: person> => |word: people>
plural |word: quantum> => |word: quanta>
plural |word: radius> => |word: radii>
plural |word: scarf> => |word: scarves>
plural |word: self> => |word: selves>
plural |word: serum> => |word: sera>
plural |word: sheaf> => |word: sheaves>
plural |word: shelf> => |word: shelves>
plural |word: sky> => |word: skies>
plural |word: stratum> => |word: strata>
plural |word: tooth> => |word: teeth>
plural |word: testis> => |word: testes>
plural |word: this> => |word: these>
plural |word: that> => |word: those>
plural |word: wife> => |word: wives>
plural |word: wolf> => |word: wolves>
plural |word: woman> => |word: women>
The dot:
digraph g {
"context" -> "learning plurals"
"context: learning plurals" -> "url: http://www.macmillandictionary.com/thesaurus-category/british/irregular-plurals" [label="source",arrowhead=normal]
"word: *" -> "merge-labels(|_self> + |s>)" [label="plural",arrowhead=box]
"word: calf" -> "word: calves" [label="plural",arrowhead=normal]
"word: child" -> "word: children" [label="plural",arrowhead=normal]
"word: corpus" -> "word: corpora" [label="plural",arrowhead=normal]
"word: elf" -> "word: elves" [label="plural",arrowhead=normal]
"word: foot" -> "word: feet" [label="plural",arrowhead=normal]
"word: goose" -> "word: geese" [label="plural",arrowhead=normal]
"word: genus" -> "word: genera" [label="plural",arrowhead=normal]
"word: half" -> "word: halves" [label="plural",arrowhead=normal]
"word: hoof" -> "word: hooves" [label="plural",arrowhead=normal]
"word: index" -> "word: indices" [label="plural",arrowhead=normal]
"word: knife" -> "word: knives" [label="plural",arrowhead=normal]
"word: leaf" -> "word: leaves" [label="plural",arrowhead=normal]
"word: life" -> "word: lives" [label="plural",arrowhead=normal]
"word: loaf" -> "word: loaves" [label="plural",arrowhead=normal]
"word: matrix" -> "word: matrices" [label="plural",arrowhead=normal]
"word: medium" -> "word: media" [label="plural",arrowhead=normal]
"word: man" -> "word: men" [label="plural",arrowhead=normal]
"word: mouse" -> "word: mice" [label="plural",arrowhead=normal]
"word: ovum" -> "word: ova" [label="plural",arrowhead=normal]
"word: ox" -> "word: oxen" [label="plural",arrowhead=normal]
"word: penny" -> "word: pence" [label="plural",arrowhead=normal]
"word: person" -> "word: people" [label="plural",arrowhead=normal]
"word: quantum" -> "word: quanta" [label="plural",arrowhead=normal]
"word: radius" -> "word: radii" [label="plural",arrowhead=normal]
"word: scarf" -> "word: scarves" [label="plural",arrowhead=normal]
"word: self" -> "word: selves" [label="plural",arrowhead=normal]
"word: serum" -> "word: sera" [label="plural",arrowhead=normal]
"word: sheaf" -> "word: sheaves" [label="plural",arrowhead=normal]
"word: shelf" -> "word: shelves" [label="plural",arrowhead=normal]
"word: sky" -> "word: skies" [label="plural",arrowhead=normal]
"word: stratum" -> "word: strata" [label="plural",arrowhead=normal]
"word: tooth" -> "word: teeth" [label="plural",arrowhead=normal]
"word: testis" -> "word: testes" [label="plural",arrowhead=normal]
"word: this" -> "word: these" [label="plural",arrowhead=normal]
"word: that" -> "word: those" [label="plural",arrowhead=normal]
"word: wife" -> "word: wives" [label="plural",arrowhead=normal]
"word: wolf" -> "word: wolves" [label="plural",arrowhead=normal]
"word: woman" -> "word: women" [label="plural",arrowhead=normal]
}
And I guess that is about it for this post.

And a brief comment. We could tweak my script still further. So far I haven't made use of this notation:
"some node" -> {"a node" "b node" "c node"}
I've been using the long form:
"some node" -> "a node"
"some node" -> "b node"
"some node" -> "c node"

But I don't know if I can be bothered to do that. I'll think about it.
I guess it shouldn't be too hard. Just use " ".join(...).


Home
previous: visualizing sw files
next: a brief look at sum of prime factors

updated: 19/12/2016
by Garry Morrison
email: garry -at- semantic-db.org