Clerk can be very helpful when exploring any kind of data, including the sorts of things for which we might turn to the Semantic Web. To give a sense of what that's like, this notebook gives some examples of querying WikiData for facts about the world.
First, we bring in Clerk, the Clerk viewer helpers, Mundaneum (a WikiData wrapper that uses a Datomic-like syntax), and Arrowic (to draw graphviz-style box-and-arrow graphs).
Now we can ask questions, like "what is James Clerk Maxwell famous for having invented or discovered?"
The WikiData internal ID :wd/Q1080745
doesn't immediately mean much to a human, so we'll try again by appending Label
to the end of the ?what
logic variable so we can see a human readable label that item:
Ah, better. 😊 This ceremony is required because WikiData uses a language-neutral data representation internally, leaving us with an extra step to get readable results. This can be a little annoying, but it does have benefits. For example, we can ask for an entity's label in every language for which it has been specified in WikiData:
One of the nice things about data encoded as a knowledge graph is that we can ask questions that are difficult to pose any other way, then receive answers as structured data for further processing.
Here, for instance, is a query asking for things discovered or invented by anyone who has as one of their occupations "physicist":
It's great that we can retrieve this information as a sequence of maps that we can explore interactively in Clerk, but sometimes it's more pleasant to display data organized in a table view:
:whatLabel | :whomLabel |
---|---|
World Wide Web | Tim Berners-Lee |
Hypertext Transfer Protocol | Tim Berners-Lee |
HyperText Markup Language | Tim Berners-Lee |
Semantic Web | Tim Berners-Lee |
WorldWideWeb | Tim Berners-Lee |
Io | Galileo Galilei |
Callisto | Galileo Galilei |
Europa | Galileo Galilei |
Ganymede | Galileo Galilei |
Trapezium Cluster | Galileo Galilei |
Galilean transformation | Galileo Galilei |
solar variation | Galileo Galilei |
Square-cube law | Galileo Galilei |
Q1535340 | Galileo Galilei |
Galilean micrometer | Galileo Galilei |
tholin | Carl Sagan |
carbon chauvinism | Carl Sagan |
Encyclopedia Galactica | Carl Sagan |
fluorine | André-Marie Ampère |
Ampère's force law | André-Marie Ampère |
480 more elided |
Once we see how a given table looks, we might decide that it would be better if, for example, these inventions were grouped by inventor. This is just the sort of thing that Clojure sequence functions can help us do:
Enrico Fermi | Monte Carlo method ; Fermi–Pasta–Ulam–Tsingou problem ; Fermi resonance ; Metrop58 more elided | | |
Al-Biruni | pycnometer | ||
Leonardo da Vinci | Leonardo's robot ; sfumato ; Coulomb friction ; Leonardo's crossbow ; Leonardo's45 more elided | | |
Joseph Fourier | Fourier–Motzkin elimination ; heat equation | ||
Albert Einstein | general relativity ; special relativity ; mass–energy equivalence ; theory of re157 more elided | | |
Luigi Galvani | galvanic cell ; galvanotherapy | ||
Carl Sagan | tholin ; carbon chauvinism ; Encyclopedia Galactica | ||
André-Marie Ampère | fluorine ; Ampère's force law ; Q3733125 | ||
Blaise Pascal | mathematical induction ; Pascal's Wager ; Pascal's calculator ; Pascal's barrel | ||
Galileo Galilei | Io ; Callisto ; Europa ; Ganymede ; Trapezium Cluster ; Galilean transformation 68 more elided | | |
Carl Friedrich Gauss | least squares method ; discrete logarithm ; Gauss's principle of least constrain159 more elided | | |
Edward Teller | Metropolis–Hastings algorithm | ||
Archimedes | Archimedean spiral ; claw of Archimedes | ||
Max Planck | Planck constant | ||
Dmitri Mendeleev | periodic table ; Mendeleev's predicted elements ; periodic trends | ||
Nikola Tesla | remote control ; three-phase electric power ; Tesla coil ; Tesla valve ; radio r44 more elided | | |
Marie Curie | polonium ; radium | ||
Tim Berners-Lee | World Wide Web ; Hypertext Transfer Protocol ; HyperText Markup Language ; Seman22 more elided | | |
Thomas Alva Edison | incandescent light bulb ; phonograph ; phonograph cylinder ; Tasimeter ; phonome51 more elided | | |
Augustin-Louis Cauchy | Root test ; Burnside's lemma ; infinitesimal deformation theory | ||
20 more elided |
Some data are more naturally viewed in other ways, of course. In this example we find every instance of any subclass of "human settlement" (village, town, city, and so on) in Germany that has a German language placename ending in -ow or -itz, both of which indicate that it was originally named by speakers of a Slavic language.
The :coordinate-location
in this query is the longitude/latitude position of each of these places in a somewhat unfortunate string fomat. The mapv
at the end converts these lonlat
strings into key/value pairs so Vega can plot the points on a map. This gives us a very clear picture of which parts of Germany were Slavic prior to the Germanic migrations:
Sometimes the data needs a more customized view. Happily, we can write arbitrary hiccup to be rendered in Clerk. We'll use this query to fetch a list of different species of Apodiformes (swifts and hummingbirds), returning a name, image, and map of home range for each one.
Green-tailed Goldenthroat | ![]() | |
Lucifer Sheartail | ![]() | |
Lucifer Sheartail | ![]() | |
Buffy Hummingbird | ![]() | |
Andean emerald | ![]() | |
Santa Marta Woodstar | ![]() | |
Ruby-throated Hummingbird | ![]() | ![]() |
Ruby-throated Hummingbird | ![]() | ![]() |
Buff-tailed Coronet | ![]() | |
Spot-throated Hummingbird | ![]() | |
Bronzy Inca | ![]() |
Another useful technique when dealing with semantic or graph-shaped data is to visualize the results as a tree. Here we gather all the languages influenced by Lisp or by languages influenced by Lisp (a transitive query across the graph), and visualize them in a big network diagram.
Because Clerk's html
viewer also understands SVGs, we can just plug in an existing graph visualization library and send the output to Clerk.
The graph is really huge, so you'll need to scroll around a bit to see all the languages.
I hope this gives you some ideas about things you might want to try!