drewp for 2007 September

<M <Y
Y> M>

T 2007-09-01T17:34:55 Data table with tabulator:

Here's how to use tabulator to render a simple data table.

/attachment/weblog/2007/09/01/0/table.png

My test data might be a bit confusing since the terms overlap with tabulator terms. I'm trying to compare query runtimes of various queries on different databases. The result I'm trying to produce is a table showing how long each database took on each query.

Here's my mockup data in n3:

@prefix : <http://example.org/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:result rdfs:label "test result" .
:db rdfs:label "database" .
:time rdfs:label "elapsed time" .

<> :result
[a :Result; :query :q1; :db :rdflibBdb; :time ".5"],
[a :Result; :query :q2; :db :rdflibBdb; :time ".6"],
[a :Result; :query :q3; :db :rdflibBdb; :time ".7"],

[a :Result; :query :q1; :db :db2; :time ".8"],
[a :Result; :query :q2; :db :db2; :time ".9"],
[a :Result; :query :q3; :db :db2; :time ".11"]
.

Note the line which associates the 6 results with this document. Without that link, tabulator won't put the results in its outline.

I used cwm to create an XML version of that data, which you can view that data in tabulator with the following link. [Update: there was no need to convert; tabulator can read n3 thanks to a version of the cwm parser translated to js with pyjs!]

tabulator with mockup data

Tabulator has a query-building interface where you click on predicates and other nodes to constrain your result rows, but I couldn't figure out how to make the table I wanted. Instead, I used the SPARQL tab at the bottom and wrote my own query:

SELECT ?query ?bdb ?db2
WHERE
{
   ?v1 <http://example.org/db> <http://example.org/db2> .
   ?v0 <http://example.org/db> <http://example.org/rdflibBdb> .
   <http://bigasterisk.com/post-rdf/timing-results6.rdf> <http://example.org/result> ?v0 .
   ?v1 <http://example.org/query> ?query .
   ?v0 <http://example.org/time> ?bdb .
   ?v0 <http://example.org/query> ?query .
   ?v1 <http://example.org/time> ?db2 .
}

In english, that says "find queries with results for the two databases, and report their times in columns named after the databases". You can load tabulator with my datafile and that query together:

tabulator with mockup data and query

You have to click the radiobutton next to 'Query' to see the results.

Now I'll actually write my database benchmark, and I'll have it output result sets for each db. I should be able to combine the result sets together and display them in a table with the method described above. The biggest issue with abusing tabulator in this way is that I have to grow my query for each new database I test. Also, that query won't display a row unless it has results from all databases. It would be nice to have all cells optional, so I can still see a row if it only has a result from one database.

T 2007-09-09T04:14:40 RDF reasoning for home automation:

Updated: fixed FuXi link

I'm trying to do my home automation with RDF and reasoning. RDF is the unified way to write all the configurations, and I'm hoping to use a logic engine (maybe FuXi or Euler) to write the control systems. Hopefully those will make it easy for humans or computers to edit the setup.

I look forward to being able to ask an N3 proof system "why is the porch light on?" and having it tell me "the web said the sun has set by now, you tripped a motion sensor within the last 15 minutes, and there was no other light shining in this area, therefore I turned on the porch light".

Tonight I cobbled together the first working version of some home automation components talking RDF. A bluetooth dongle constantly searches for devices, and if it finds one, it states that [the bluetooth sensor] [senses] [the URI for the device]. Here's that program.

(BTW, avoid bluetooth chips by Integrated System Solution Corp and prefer ones by Cambridge Silicon Radio. The ISSC one I got has the lousy address 11:11:11:11:11:11 that's hard to change since I'm not using windows. Also, this bluetooth intro is really good.)

Next in my home automation system, a reasoning program hears about new statements and executes the right logic to produce more statements about what should happen. This program is a stub for now- it just turns the presence of my phone into a statement to power the door lock. But devices.n3 suggests what some of the logic might eventually look like.

Finally, an output program has been watching for statements about pins on the parallel port it controls. The reasoning program said to put power on bit2, so this program sets the output accordingly. On that pin is a circuit with an optoisolator, a triac, a transformer, and the electric strike that releases the door.

When the real logic is in place, the proof system should be able to say "I unlocked the door because someone friendly was nearby, because Drew is friendly and Drew carries a phone with the bluetooth address I saw".


[Main]

Unless otherwise noted, all content licensed by Drew Perttula
under a Creative Commons License.