[foaf-dev] FOAF pathfinder code: anyone care to update it? (Ruby,
danbri at danbri.org
Wed Apr 2 23:53:19 BST 2008
just rediscovered this:
It's a mechanic transformation of Damian/Libby's old Java code, see
This is all about finding paths through FOAF data. It should be
applicable to XFN equally well. "Find me the path from Dan to John" or
"Find me the path from Enron to Semantic Web Vapourware Ltd.', ...
My old pathfinder.rb used the RubyRdf library as a query service; the
dependency is pretty weak, but I'd love to see this modernised/renovated
pathfinding capabilities in it, if you view source. See
http://www.jibbering.com/foaf/ and nearby. There are various forms of
graph edge that we might pathfind over; my favourite is codepiction,
where two people are in the same photo (damian's writeup covers this)
and corporate relations (he covers that too). But simple foaf:knows or
xfn:contact would be great as well...
Libby's codepiction pathfinder service is down currently, but was
running fairly recently (albeit over old data),
Here's the core Squish query I used:
SELECT ?mbox1, ?mbox2, ?uri,
(foaf::depiction ?x ?img)
(foaf::depiction ?z ?img)
(foaf::thumbnail ?img ?uri)
(foaf::mbox ?x ?mbox1)
(foaf::mbox ?z ?mbox2)
USING foaf for http://xmlns.com/foaf/0.1/
the transformation to SPARQLwould be just:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?mbox1 ?mbox2 ?uri
?x foaf:depiction ?img .
?z foaf:depiction ?img .
?img foaf:thumbnail ?uri .
?x foaf:mbox ?mbox1 .
?z foaf:mbox ?mbox2 .
... ie. pretty basic stuff. You could do more work to deal with other
ways of identifying people, and normalising nodes (smushing) of course.
If you rip out and replace this piece of code,
q = SquishQuery.new.parseFromText query
DBI.connect ('DBI:Pg:rdfweb1','danbri','') do | dbh |
dbh.select_all( q.toSQLQuery ) do | row |
# print '.' # progressometer
p = ResultRow.new(row)
graph.addPath(p.mbox1, p.mbox2, p.uri)
with a SPARQL client (eg.
http://svn.foaf-project.org/foaftown/2008/ruby-sparql-client/ ) you
should be most of the way there.
I'm crossposting this to the FOAF foaf-dev list and the W3C list I set
up for RDF/Ruby collaborations. The latter has been dissapointingly
quiet for a while. C'mon people, I know you're out there!! ;) If you're
a Ruby person and not on the list,
http://lists.w3.org/Archives/Public/public-rdf-ruby ... see
http://danbri.org/words/2008/02/08/270 for background and signup
instuctions. I'll even repeat it here: to join send any email to
public-rdf-ruby-request at w3.org with a subject line of “subscribe”. Ruby
people, please talk to each other! You know you want to... :)
Back re pathfinder: I think this is really a great time to revisit this
problem space. We now have Google building a global index of FOAF files
(and using a real RDF parser),
http://code.google.com/apis/socialgraph/docs/testparse.html ... and
there's also a lot of Microformat XFN data out there too (which btw
should make people here happy). And Amazon offer EC2 which allows us to
have (in exchange for money, admittedly) access to a pile of cloned
virtual Linux boxes to do our bidding. Rebuilding (and redesigning) the
FOAF pathfinder demos seems an approachable and timely thing to explore.
EC2 users can also easily setup OpenLink Virtuoso servers pretty much
with a single click. Interesting times :)
More information about the foaf-dev