Playing with Sparql – proximity based service queries

Playing with SPARQL, after downloading Joseki and Protégé:

Steps 1 – Copied books.n3 (and an edited version newbooks.n3) to a web server (see From below):

PREFIX dc:      <http://purl.org/dc/elements/1.1/>
SELECT ?book ?title
FROM <http://people.brunel.ac.uk/~csstdjb/ontology/newbooks.n3>
WHERE
  { ?book dc:title ?title }

Returns a book list!

Step 2 – Create a service list that uses DC – call this servicedc.n3

PREFIX dc:      <http://purl.org/dc/elements/1.1/>
SELECT ?service ?title ?creator
FROM <http://people.brunel.ac.uk/~csstdjb/ontology/servicedc.n3>
WHERE
  { ?service dc:title ?title }

// Creator is empty?

Step 3 – change DB to UBIS (an OWL ontology) and use ServiceName Place

PREFIX ubi:        <http://people.brunel.ac.uk/~csstdjb/ontology/UBIS.owl#>
SELECT ?service ?ServiceName
FROM <http://people.brunel.ac.uk/~csstdjb/ontology/SSS.n3>
WHERE
{
    ?service ubi:ServiceName ?ServiceName
}

Step 4 – Display Place

PREFIX ubi:        <http://people.brunel.ac.uk/~csstdjb/ontology/UBIS.owl#>
SELECT ?service ?ServiceName ?Place
FROM <http://people.brunel.ac.uk/~csstdjb/ontology/SSS.n3>
WHERE
{
    ?service ubi:ServiceName ?ServiceName .
    ?loc   ubi:Place       ?Place
}

Step 4 – Add a clause – place = IBM
 
PREFIX ubi:        <http://people.brunel.ac.uk/~csstdjb/ontology/UBIS.owl#>
SELECT ?service ?ServiceName ?Place
FROM <http://people.brunel.ac.uk/~csstdjb/ontology/SSS.n3>
WHERE
{
    ?service ubi:ServiceName ?ServiceName .
    ?loc   ubi:Place       ?Place
    FILTER regex(?Place, “IBM”)

}

// Odd – all places set to IBM – expecting only 1

PREFIX ubi:        <http://people.brunel.ac.uk/~csstdjb/ontology/UBIS.owl#>
SELECT ?service ?ServiceName ?Place
FROM <http://people.brunel.ac.uk/~csstdjb/ontology/SSS.n3>
WHERE
{
    ?loc   ubi:Place  “IBM” .
    ?loc   ubi:Place  ?Place .
}

// This just returns IBM – getting nearer

PREFIX ubi:        <http://people.brunel.ac.uk/~csstdjb/ontology/UBIS.owl#>
SELECT ?service ?ServiceName ?Place
FROM <http://people.brunel.ac.uk/~csstdjb/ontology/SSS.n3>
WHERE
{
    ?loc   ubi:Place  “IBM” .
    ?loc   ubi:Place  ?Place .
    ?loc ubi:ServiceName ?ServiceName .
}

// Now just to get the service name

Step 5 – Change Place to Object and Proximity (IBM Foyer, 80)

Data:

@prefix ubi:       <http://people.brunel.ac.uk/~csstdjb/ontology/UBIS.owl#> .
@prefix ns:        <http://example.org/ns#> .
@prefix :          <http://example.org/services/> .

:service1
    ubi:CapabilityName  “getRates” ;
    ubi:Object     “Foyer” ;
    ubi:Proximity    50 ;
    ubi:Place                    “IBM” .
   
:service2
    ubi:CapabilityName “getRates” ;
    ubi:Object                 “Foyer” ;
    ubi:Proximity   30 ;
    ubi:Place                   “BBC” .
   
:service3
    ubi:CapabilityName “getRates” ;
    ubi:Object                “Trader1” ;
    ubi:Proximity  5 ;
    ubi:Place                  “MS” .

Query:

PREFIX ubi:        <http://people.brunel.ac.uk/~csstdjb/ontology/UBIS.owl#>
SELECT ?service ?CapabilityName ?Place
FROM <http://people.brunel.ac.uk/~csstdjb/ontology/SSS.n3>
WHERE
{
    ?loc   ubi:Place  “IBM” .
    ?loc   ubi:Object “Foyer” .
    ?loc   ubi:Place  ?Place .
    ?loc   ubi:CapabilityName ?CapabilityName .
    ?loc   ubi:Proximity ?Proximity .
    FILTER (?Proximity < 80) .

}

Step – Move Service Name, Object and Proximity as subclasses of Service concept class (& try some of above queries)

Worked with same sparql!

PREFIX ubi:        <http://people.brunel.ac.uk/~csstdjb/ontology/UBIS.owl#>
SELECT ?CapabilityName ?Place
FROM <http://people.brunel.ac.uk/~csstdjb/ontology/SSS.n3>
WHERE
{
    ?loc   ubi:Place  “IBM” .
    ?loc   ubi:Object “Foyer” .
    ?loc   ubi:Place  ?Place .
    ?loc   ubi:CapabilityName ?CapabilityName .
    ?loc   ubi:Proximity ?Proximity .
    FILTER (?Proximity < 80) .

}

This is the start of a paper I will be presenting as ESBE 2009 (at MCIS 2009).

Next – the old problem of selecting all that are either a specific class or its subclasses….

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s