W3C home > Mailing lists > Public > public-wai-ert@w3.org > July 2006

[Fwd: Matching URIs in RDF (with SPARQL)]

From: Shadi Abou-Zahra <shadi@w3.org>
Date: Mon, 03 Jul 2006 15:04:40 +0200
Message-ID: <44A915E8.6060207@w3.org>
To: public-wai-ert@w3.org
Cc: Dan Brickley <danbri@danbri.org>

Hi,

Pretty interesting for ERT WG too. Specifically the pattern matching requirements specified by the XG:
  <http://www.w3.org/2005/Incubator/wcl/matching>


We had previously explored some of this for EARL but never came to a conclusion. Comments welcome...

Best,
  Shadi


-------- Original Message --------
Subject: Matching URIs in RDF (with SPARQL)
Date: Sat, 01 Jul 2006 12:03:36 +0100
From: Dan Brickley <danbri@danbri.org>
To: public-xg-wcl@w3.org


(Am sending this to the XG's public list, bcc:'d to the member one. 
We're all on both, right? it's a good discussion to have in public...)


OK Some progress, based on the regex from Jo's doc. Rough notes from the 
SW Interest Group IRC channel, where I got some help putting this 
together. I've got a quick perl script that generates an RDF description 
of each entry in a list of URIs, and a SPARQL query plus various filters 
which match against some/all of these URIs. It uses a fictional 
namespace in http://www.w3.org/2004/12/q/ which reminds me to 
investigate whether I still have write-access there, and if we can use 
it for the XG.

Am Cc:'ing TimBL and DanC who may be interested. Tim, Dan --- this work 
is motivated by a desire to attach RDF descriptive labels to collections 
of documents picked out either by enumeration or by patterns expressed 
against URIs/IRIs. Jo Rabin's doc at 
http://www.w3.org/2005/Incubator/wcl/matching.html has more background.
There's some related work from OpenSearch folks at 
http://www.snellspace.com/wp/?p=369 that we're loosly connected to via 
Elias Torres in #swig.


For today's hack, see 
http://swig.xmlhack.com/2006/07/01/2006-07-01.html#1151749799.081592

Perl script:       http://spypixel.com/2006/wcl/uri/uri-pl-source.txt
List of URIs:      http://spypixel.com/2006/wcl/uri/sites.txt
Generated RDF:     http://spypixel.com/2006/wcl/uri/_data.rdf

example:
<ID xmlns='http://www.w3.org/2004/12/q/idsyntax#'>
<full>http://nobody:nothing@127.0.0.1:8080/dot/slash/dot?foo=bar;x=y</full>
  <nameFor 
rdf:resource='http://nobody:nothing@127.0.0.1:8080/dot/slash/dot?foo=bar;x=y'/> 

  <scheme>http</scheme>
  <authority>nobody:nothing@127.0.0.1:8080</authority>
  <userinfo>nobody:nothing</userinfo>
  <host>127.0.0.1</host>
  <port>8080</port>
  <path>/dot/slash/dot</path>
  <query>foo=bar;x=y</query>
</ID>

Example SPARQL:    http://spypixel.com/2006/wcl/uri/filter-test2.rq
(this runs OK in Jena/ARQ eg through the Twinkle GUI)

Here's the SPARQL example in full. Basically we match the URI 
descriptions, and then filter against the various strings using the
query language's FILTER functionality, in particular, regexs, and/or 
stuff, and exact matching with "=". The lines with a # are commented 
out. Note that there are some cases here we'll want for testing, eg. 
case of the URI scheme (hTtp: etc) could easily trip us up.

PREFIX u: <http://www.w3.org/2004/12/q/idsyntax#>
SELECT DISTINCT *
WHERE {
  ?id a u:ID .
  ?id u:full ?full .
  ?id u:nameFor ?res .
  ?id u:scheme ?scheme .
  ?id u:authority ?authority .
  OPTIONAL { ?id u:userinfo ?userinfo } .
  OPTIONAL { ?id u:host ?host } .
  OPTIONAL { ?id u:port ?port } .
  OPTIONAL { ?id u:path ?path } .
  OPTIONAL { ?id u:query ?query } .
  OPTIONAL { ?id u:fragment ?fragment } .
#  FILTER regex ( ?scheme, "http" ) . # schemes matching "http" ie.
includes https:
#  FILTER regex ( ?scheme, "^http$" ) . # http: scheme
#  FILTER regex ( ?scheme, "^HTTP$" ) . # HTTP: scheme (do we normalise
in the regex or the rdf?)
#  FILTER regex ( ?scheme, "^http$", "i" ) . # http: scheme, case
insensitive (more robust)
# FILTER regex(?scheme,"^http$","i")  && ( (?port = "8080") || (?port =
"1234") ).
#FILTER regex(?userinfo, ":") # password is given in the URI
FILTER regex(?host, "^pics|www\.pics") .
}



Easiest way to play with this is to download and run Twinkle from 
http://www.ldodds.com/projects/twinkle/ and use 
http://spypixel.com/2006/wcl/uri/_data.rdf as the data URI.

I've not got it running against the online Redland SPARQL query 
installation yet, will ask Dave Beckett where the problem is.

There are a few more comprehensive collections of 'tricky' URIs around, 
I'm not sure the exact status of any URI test suite but have collected 
up some links in the bottom of the perl script, reproduced here.

http://www.w3.org/Addressing/url_test/url_grammar.tests
http://www.ninebynine.org/Software/HaskellUtils/Network/URITestDescriptions.html
http://www.w3.org/2001/Talks/0912-IUC-IRI/paper.html

I've not investigated the IRI side yet, nor taken any care with charset 
issues (either in the data, or the perl/regex).

Next steps in the XG? It would be great if someone could try 
re-expressing the contents of 
www.w3.org/2005/Incubator/wcl/matching.html or Phil's recent msg 
http://lists.w3.org/Archives/Member/member-xg-wcl/2006Jun/0079.html 
(member-only link) using SPARQL filters plus this vocab. For those of us 
who prefer to do things with XML, I wonder whether the XML resultset 
format that SPARQL returns would be an acceptable compromise. If we run 
the above SPARQL query without any filters, it returns the following XML 
structure --- http://spypixel.com/2006/wcl/uri/_eg_results.txt

ie. markup like this:

    <result>
      <id bnodeid="b0"/>
      <full>http://example.caps.example.org/</full>
      <res uri="http://example.caps.example.org/"/>
      <scheme>HTTP</scheme>
      <authority>example.caps.example.org</authority>
      <userinfo bound="false"/>
      <host>example.caps.example.org</host>
      <port bound="false"/>
      <path>/</path>
      <query bound="false"/>
      <fragment bound="false"/>
    </result>

...for each result. Am thinking out loud here, not yet quite sure how 
all these ingredients fit together. And that's without even considering 
OWL, RIF etc. :)

cheers,

Dan




-- 
Shadi Abou-Zahra     Web Accessibility Specialist for Europe | 
Chair & Staff Contact for the Evaluation and Repair Tools WG | 
World Wide Web Consortium (W3C)           http://www.w3.org/ | 
Web Accessibility Initiative (WAI),   http://www.w3.org/WAI/ | 
WAI-TIES Project,                http://www.w3.org/WAI/TIES/ | 
Evaluation and Repair Tools WG,    http://www.w3.org/WAI/ER/ | 
2004, Route des Lucioles - 06560,  Sophia-Antipolis - France | 
Voice: +33(0)4 92 38 50 64          Fax: +33(0)4 92 38 78 22 | 
Received on Monday, 3 July 2006 13:04:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:18:27 GMT