Thursday, March 30, 2006, 11:53 PM
- RDF, Python
Too late to be verbose now, but after being encouraged by Danny last week, I've spent long evening hacking together this crappy demo. The webpage has all the info you need (including downloads), and the screenshot here should tickle your senses enough to click that link. If you like RDF that is. And you like old-fashioned computer games. And if you're bored. 
Some notes:
- Look at some RDF DATA, schemas dont work well just now.
- Yes i know the fire effect is badly aligned.
- You need data with rdfs:seeAlso links to get doors.
That's it for now, I refuse to waste any more time on this useless nonsense!
(Oh, and I submitted this to the ESWC Semantic Web Scripting Challenge :-)
[ 1 comment ] ( 704 views ) | permalink |




( 3 / 4994 )Tuesday, March 21, 2006, 08:34 PM
- Java
(I try again, with considerably less love than last time)
Opening files in their "natural" application was something I knew had to be done sooner or later for aperture/gnowsis/nepomuk, but I put it off for as long as possible because I had a horrible feeling that to get it to work on all platforms it would be long and messy and maybe involve nasty C code.
Imagine my surprise when in a few hours today I got it working for files, directories and web links, and this on both windows, macosx and linux (kde/gnome). All without leaving the world of Java. The code is so short I will paste it here (beautifully formatted by code2html!)
private void windowsopen(URI uri) throws IOException {
Runtime.getRuntime().exec(
new String [] { "rundll32", "url.dll,FileProtocolHandler",uri.toString() });
}
private void linuxopen(URI uri) throws IOException {
// TODO: I don't know how reliable this is.
// It's set correctly for kde/gnome on my machine
if (System.getenv("DESKTOP_SESSION").toLowerCase().contains("kde")) {
//kde:
Runtime.getRuntime().exec(new String [] { "kfmclient","exec",uri.toString()} );
} else {
//Default to gnome as it complains less if it's not running.
Runtime.getRuntime().exec(new String [] { "gnome-open",uri.toString()} );
}
}
private void macopen(URI url) throws IOException {
try {
Class macopener = Class.forName("com.apple.eio.FileManager");
Method m = macopener.getMethod("openURL",new Class[] {String.class});
m.invoke(null,new Object[] {url.toString()});
} catch (Exception e) {
throw new IOException("Could not open URI: "+url+" - "+e);
}
}
This is for opening http links, but the file code is almost identical, KDE and Windows doesn't like file:// URIs so I convert them to filenames first, and launching things in Windows is done by executing "cmd /c blah" instead (Thanks Michael Sintek!).
Still damn easy. It's not very well tested yet - but it works on my three instances of each OS! If anyone feels like testing it the code is in the aperture cvs repos, FileOpener.java and HttpOpener.java (although it's only just committed so it'll take a while for the sourceforge cvs mirrors to catch up)
[ 2 comments ] ( 44 views ) | permalink |




( 3 / 2065 )Tuesday, March 21, 2006, 07:47 PM
- Everything Else
It wasn't horribly long, but it was full of love! The session timed out or something, and when I hit the preview button I got 403 and when I went back the text was all gone. Bastards. That will teach me to draft the entries in something that isn't firefox... Oh well. I might rewrite it later.
[ 2 comments ] ( 30 views ) | permalink |




( 3 / 4145 )Monday, March 13, 2006, 09:11 PM
- RDF, PhD
Recently I decided that for the planning part of Smeagol it would make sense if all the avaiable actions were specified in RDF. This seemed sensible since I was re-factoring the action/planning part of Smeagol anyway - it was all pretty much coded in one coffee fuelled weekend just before some paper deadline and was now completely incomprehensible to anyone. Moving to RDF also seemed right and elegant because I enjoy moving "things" into a more explicit and structured format; like my very first thoughts on the internal structuring of Smeagol moved from being hard-coded to being dynamically planned, or how someone (Malte?) pointed out that Semantic Wikis and the [ur=http://en.wikipedia.org/wiki/Infobox]Infoboxes[/url] of wikipedia are steps on a road where soon all content will be represented in structured form.
Anyway, I digress. An action in Smeagol now looks like this:
(I steal freely from N3 Rules and cwm in general).
@prefix : <http://www.csd.abdn.ac.uk/~ggrimnes/dev/smeagol/ontology#>.
@prefix ac: <http://www.csd.abdn.ac.uk/~ggrimnes/dev/smeagol/actions#>.
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
ac:read a :Action ;
rdfs:label "read" ;
:in ( ?u ) ;
:out () ;
:preconditions { ?u :source ?source . ?u :triples ?t1 } ;
:effects { ?u :triples ?t2 . ?t2 math:greaterThan ?t1} .
This represents an action "read something about this URI (?u)" - it needs a source of information about this uri to be known beforehand, and if executed it will result in Smeagol knowing more triples about ?u that we did before. Hardly rocket science, but I like the idea of using :triples as a magic property, which is evaluated rather than looked up in the graph. The idea is of course old, cause cwm and n3 rules/queries do exactly the same with builtin functions. Oh well - this time I got the idea from the handling of full-text lucene queries in sparql as done in Gnowsis.
So this evening I finished the planning module of Smeagol, and while I was developing it I used a list of only 2 actions for testing. And when it appeared to work I uncommented the other actions in the n3 file, and whoho! It just worked! And 4 different plans were generated! ... and then I thought of the subject line and sniggered to myself.
[ add comment ] | permalink |




( 3 / 2037 )Thursday, March 9, 2006, 04:00 PM
- Semantic Desktop, Python, Java
Plan for Today: write an Aperture datasource for the thunderbird addressbook, this to pass time before lunch while I didn't have my mac, and should be quick and easy. Fast forward till lunchtime, where I've found that Thunderbird uses the MORK format for it's addressbook. Mork is a "barely machine readable", "stupidest file format I've ever seen", "look-ma-I-wrote-a-DB" excuse for a DB format.
It was designed by some netscape engineer in the 90s who then disappeared and now no-one knows how it works. It looks a bit like this:
<(91=2)(81=Test)(82=Bob)(83=)(84=Test Bob)(87=bobnickname)(85
=bob@tester.com)(88=bobby@serial.co.uk)(80=0)(89=workphone)(8A
=homephone)(8B=faxphone)(8C=papegerphone)(8D=mobphone)(8E
=bobscreenname)(8F=441048b8)(86=1)(90=bill)>
{1:^80 {(k^BF:c)(s=9)}
[1:^82(^BE=2)]
[1(^83^81)(^84^82)(^85=)(^86=)(^87^84)(^88^87)(^89^85)(^8A^85)(^8B^88)
(^8C=)(^8D=)(^8E=0)(^8F=0)(^90^89)(^91^8A)(^92^8B)(^93^8C)(^94^8D)
(^95=)(^96=)(^97=)(^98=)(^99=)(^9A=)(^9B=)(^9C=)(^9D=)(^9E=)(^9F=)...
Luckily someone else has sort of reverse-engineered it, and there exist partial perl parser and one python version.
I've now added to the madness by converting the python one to Java. It sucked and took all day. (And someone pointed out I could have done it with jython, oh well). To make up for it I'm going to share it with the world.
Here download a jar with src/binaries and some examples:
UPDATED! The old version did not handle encoding of non-ascii characters too well - like everything else in mork this was pretty badly done, but now it's working.
http://www.dfki.uni-kl.de/~grimnes/2006 ... st-0.2.jar
[ 3 comments ] ( 111 views ) | permalink |




( 3.1 / 4790 )Back Next



