#!/usr/bin/env ruby # # $Id: webfetch_tests.rb,v 1.2 2002/04/01 05:30:47 danbri Exp $ # Dan Brickley # This script exercises the WebFetch-powered wrapper for web queries # # Here we show how remote web query can be merged against locally queried info # # Demo: we ask google for backlinks to a site, then check to see if # any of the referencing sites are listed in the economics event feed. # ie. 'notify me of economics events associated with Bloomfield House'. require '../squish' require '../../basicrdf' squish='SELECT ?item, ?title, ?etype, ?org, ?loc, ?start, ?end, WHERE (rss::title ?item ?title) (ev::type ?item ?etype) (ev::organizer ?item ?org) (ev::location ?item ?loc) (ev::startdate ?item ?start) (ev::enddate ?item ?end) USING rss for http://purl.org/rss/1.0/ ev for http://purl.org/rss/1.0/modules/event/ foaf for http://xmlns.com/foaf/0.1/ ' # Query google for (max 100) docs that link to this one: # url = 'http://www.bloomfieldhouse.com/' backlinks = SquishQuery.googleBacklinks url, 'item' # Find out if they're in our RSS event listings: # eventfeed = Loader.ntfile2graph 'events.nt' events = SquishQuery.ask SquishQuery.new.parseFromText(squish), eventfeed total = events.match backlinks, 'item' # merge in the backlinks table total.each do |row| row.values.each_key do |field| puts "\t#{field}: #{row.values[field]} \n" end puts "\n\n" end =begin notes... # test docs that are referenced by event websites: # url = 'http://www.niss.ac.uk/cr/events/manevent.html' # url = 'http://pythie.cepremap.cnrs.fr/sce2002/' # url = 'http://www.ltsn.ac.uk/genericcentre/' # url = 'http://rfe.wustl.edu/Conferences/index.html' One record was in the event listing and also (according to Google) referenced the url 'http://www.bloomfieldhouse.com/': loc: "Mullingar, Republic of Ireland" title: "IEA Annual Conference 2002" org: "Irish Economic Association" end: "2002-04-14" start: "2002-04-12" item: http://www.iea.ie/conferences/ etype: "Conference" =end