WP6+WP3 session on LB-SMA during Lund plenary

Lund, 11th May 2011

Participants

Agenda

Discussion

Objective setting

Check of current state

% SEE QUERY NUMBER '''20''' IN THE ECLIPSE PROJECT
% bot: prefix indicates the "Lyon" ontology
SELECT ?poi ?name ?lat ?long ?altitude ?category ?numPos ?numNeu ?numNeg
WHERE {
?poi a bot:NamedPlace ;
     bot:name ?name ;
     geo:lat ?lat ;
     geo:long ?long ;
     geo:alt ?altitude ;
     skos:subject ?category .
OPTIONAL { ?poi bot:numeberOfPositiveTweets ?numPos . }
OPTIONAL { ?poi bot:numeberOfNeutralTweets ?numNeu . }
OPTIONAL { ?poi bot:numeberOfNegativeTweets ?numNeg . }
FILTER( ?lat>"45.46"^^xsd:float
     && ?lat<"45.47"^^xsd:float
     && ?long>"9.18"^^xsd:float
     && ?long<"9.20"^^xsd:float )  % the coordinates are just examples; datatype TO-FIX
}

PROBLEMS, COMMENTS and TASKS

  • add bot:numeberOfPositiveTweets, bot:numeberOfNeutralTweets, bot:numeberOfNegativeTweets to the ontology
  • shall we use skos:subject instead of bot:category ?
  • in the final version we should change the filter clause introducing something like distance(POINT(?lat,?log), POINT("45.56","9.45"))<"100"meters

% SEE QUERY NUMBER '''21''' IN THE ECLIPSE PROJECT
SELECT ?poi ?lat ?long?category
WHERE {
 data:ZuccaInGalleria a bot:NamedPlace ;
                      geo:lat ?givenLat ;
                      geo:long ?givenLong ;
                      skos:subject ?category .
 ?poi a bot:NamedPlace ;
      geo:lat ?lat ;
      geo:long ?long ;
      skos:subject ?category . % same category as before
 FILTER (?poi!=data:ZuccaInGalleria) % different poi
 FILTER(
   (?lat-?givenLat)<"0.1"^^xsd:float &&
   (?lat-?givenLat)>"-0.1"^^xsd:float &&
   (?long-?givenLong)<"0.1"^^xsd:float  &&
   (?long-?givenLong)>"-0.1"^^xsd:float
 )
}

PROBLEMS, COMMENTS and TASKS

  • in the final version we should change the filter clause that naively computes distance based on the lat, givenLat, long and givenlong introducing something like distance(POINT(?lat,?long), POINT("?givenLat","?givenLong"))<"100"meters

SELECT ?poi ?lat ?long?category
WHERE {
 data:ZuccaInGalleria a bot:NamedPlace ;
                      geo:lat ?givenLat ;
                      geo:long ?givenLong  .
 ?poi a bot:NamedPlace ;
      geo:lat ?lat ;
      geo:long ?long .
 FILTER (?poi!=data:ZuccaInGalleria)
 FILTER(
  (?lat-?givenLat)<"0.1"^^xsd:float &&
  (?lat-?givenLat)>"-0.1"^^xsd:float &&
  (?long-?givenLong)<"0.1"^^xsd:float  &&
  (?long-?givenLong)>"-0.1"^^xsd:float )
 data:ZuccaInGalleria bot:similar ?poi . WITH PROB ?p
  % for the actual "implementation" of SPARQL with probabilities, see next query and the discussion below
}
ORDER BY DESC(?p) % higher probability first
LIMIT 10

% SEE QUERY NUMBER '''23''' IN THE ECPLISE PROJECT
PREFIX f: <java:ext.>
SELECT ?poi ?lat ?long ?category (f:similarWithProbability(data:ZuccaInGalleria,?poi) AS ?p )
WHERE {
 data:ZuccaInGalleria a bot:NamedPlace ;
                      geo:lat ?givenLat ;
                      geo:long ?givenLong  .
 ?poi a bot:NamedPlace ;
      geo:lat ?lat ;
      geo:long ?long .
 FILTER (?poi!=data:ZuccaInGalleria)
 FILTER((?lat-?givenLat)<"0.1"^^xsd:float &&
        (?lat-?givenLat)>"-0.1"^^xsd:float &&
        (?long-?givenLong)<"0.1"^^xsd:float  &&
        (?long-?givenLong)>"-0.1"^^xsd:float )
 data:ZuccaInGalleria bot:similar ?poi .
}
ORDER BY DESC(?p)
LIMIT 10

PROBLEMS, COMMENTS and TASKS

  • those inherited by previous queries
  • substitute the current dummy implementation of the custom function similarWithProbability(IRIa,IRIb) with one that invoke SUNS
  • check if LarKC endpoint accepts this queries that include custom functions

SELECT ?poi ?name ?category ?p
WHERE {
 <http://bottari.kr/GiulioPaneOlio> geo:alt ?lat ; % sample current POI
                                    geo:long ?long  ;
                                    bot:category ?category .
 ?poi geo:alt ?lat1 ; % target POI
      geo:long ?long1 ;
      bot:name ?name ;
      bot:category ?category . % same category of the current POI
 FILTER (distance(POINT(?lat,?log), POINT(?lat1,?long1))<"100"^^meters) % filter on the distance; datatype TO-FIX

 <http://bottari.kr/Emanuele> bot:post [
                    bot:talksPositivelyAbout ?poi ]
                    . WITH PROB ?p % probability that the current user will twitter positively about this POI
 % for the actual "implementation" of SPARQL with probabilities, see below
}
ORDER BY ?p
LIMIT 10

% SEE QUERY NUMBER '''24''' IN THE ECPLISE PROJECT
PREFIX f: <java:ext.>
SELECT ?poi ?name ?category (f:talksAboutPositivelyWithProbability(data:Alice,?poi) AS ?p )
WHERE {
 data:ZuccaInGalleria a bot:NamedPlace ;
      geo:lat ?givenLat ;
      geo:long ?givenLong ;
      skos:subject ?category .
 ?poi a bot:NamedPlace ;
      geo:lat ?lat ;
      geo:long ?long ;
      skos:subject ?category .
 FILTER (?poi!=data:ZuccaInGalleria)
 FILTER((?lat-?givenLat)<"0.1"^^xsd:float &&
        (?lat-?givenLat)>"-0.1"^^xsd:float &&
        (?long-?givenLong)<"0.1"^^xsd:float  &&
        (?long-?givenLong)>"-0.1"^^xsd:float )
 data:Alice bot:posts ?tweet .
 ?tweet bot:talksAboutPositively ?poi .
 FILTER(f:talksAboutPositivelyWithProbability(data:Alice,?poi)>0.5)
}
ORDER BY DESC(?p)
LIMIT 10

PROBLEMS, COMMENTS and TASKS

  • those inherited by previous queries
  • substitute the current dummy implementation of the custom function talksAboutPositivelyWithProbability(IRIa,IRIb) with one that invoke SUNS

SELECT ?poi (COUNT(?positiveTweet) AS ?numPos) (COUNT(?negativeTweet) AS ?numNeg) (COUNT(?neutralTweet) AS ?numNeu)
FROM STREAM <http://bottari.kr/streamOftweets> [10d STEP 1d] % register the stream of twitter to consider and the time window
WHERE {
 {
  ?positiveTweet a bot:Tweet ;
                 bot:talksPositivelyAbout ?poi .
 } UNION
 {
  ?negativeTweet a bot:Tweet ;
                 bot:talksNegativelyAbout ?poi .
 } UNION
 {
  ?neutralTweet a bot:Tweet ;
                bot:talksNeutrallyAbout ?poi .
 }
}

SELECT ?poi ?user (similarity(<http://bottari.kr/Emanuele>, ?user) AS ?p)
FROM STREAM <http://bottari.kr/streamOftweets> [1h STEP 10m]
WHERE {
  ?user bot:post ?t . % target user tweeted
  ?t bot:talksPositivelyAbout ?poi . % his tweet was about a poi
  ?poi geo:lat ?lat; % target poi has a position and category
       geo:long ?long ;
           bot:category ?category .
  <http://bottari.kr/Emanuele> geo:lat ?e-lat; % position of current user
                               geo:long ?e-long ;
                                                           bot:post ?e-t . % current user tweeted
  ?e-t bot:talksPositivelyAbout ?e-poi; % his tweet was about another poi
  ?e-poi category ?category . % the other poi had the same category of the target one
  FILTER (distance(POINT(?lat,?log), POINT(?e-lat,?e-long))<"1000"^^meters) % the target poi is close to the current user
}
ORDER BY ?p
LIMIT 10

% SEE QUERY NUMBER '''25''' IN THE ECPLISE PROJECT
PREFIX f: <java:ext.>
SELECT ?poi1 ?poi2 ?user (f:similarWithProbability(data:Alice, ?user) AS ?p) 
WHERE {
 ?user bot:posts ?t1 . 
 ?t1 bot:talksAboutPositively ?poi1 . 
 ?poi1 a bot:NamedPlace ;
       geo:lat ?lat1 ;
       geo:long ?long1 ;
       skos:subject ?category .
 data:Alice geo:lat ?givenLat ;
            geo:long ?givenLong ; 
            bot:posts ?t2 .
 ?t2 bot:talksAboutPositively ?poi2 .
 ?poi2 a bot:NamedPlace ;
       geo:lat ?lat2 ;
       geo:long ?long2 ;
       skos:subject ?category .
 FILTER(?t1!=?t2)
 FILTER(f:similarWithProbability(data:Alice, ?user)>0.5)
 FILTER((?lat1-?givenLat)<"0.1"^^xsd:float &&
        (?lat1-?givenLat)>"-0.1"^^xsd:float &&
        (?long1-?givenLong)<"0.1"^^xsd:float  &&
        (?long1-?givenLong)>"-0.1"^^xsd:float )
}  
ORDER BY DESC(?p)
LIMIT 10

PROBLEMS, COMMENTS and TASKS

  • the text of the query does not match the query itself. I did my best to implement it, but I'm not sure if I got it right

SELECT ?user ?nextPoi (probability(?user, ?nextPoi) AS ?p)
FROM STREAM <http://bottari.kr/streamOftweets> [1h STEP 10m]
WHERE {
  ?user bot:post ?t . % target user tweeted
  ?t bot:talksAbout ?poi . % his tweet was about a poi
  ?poi geo:lat ?lat; % that poi was in a position
       geo:long ?long .
  <http://bottari.kr/Emanuele> geo:lat ?e-lat; % the current user is in a position
                               geo:long ?e-long .
  FILTER (distance(POINT(?lat,?log), POINT(?e-lat,?e-long))<"1000"^^meters) % the location of the poi is close to the current user

  ?user bot:post [ bot:talksPositivelyAbout ?nextPoi ] . % the target user could tweet about another target poi
  FILTER ( probability(?user, ?nextPoi) <1 ) % but he hasn't done it yet (otherwise the probability would have been 1)
  ?nextPoi geo:lat ?nextLat; % the target poi is in a position
           geo:long ?nextLong .
  FILTER (distance(POINT(? nextLat,?nextLong), POINT(?e-lat,?e-long))<"1000"^^meters) % the target poi is close to the current user
}
ORDER BY ?p
LIMIT 10

% SEE QUERY NUMBER '''26''' IN THE ECPLISE PROJECT
PREFIX f: <java:ext.> 
SELECT ?user ?nextPoi (f:talksAboutPositivelyWithProbability(?user,?nextPoi) AS ?p ) AS ?p )
WHERE {
 ?user bot:posts ?t1 .
 ?t1 bot:talksAboutPositively ?poi1 .
 ?poi1 a bot:NamedPlace ;
       geo:lat ?lat ;
       geo:long ?long  .
 data:Alice geo:lat ?givenLat ;
            geo:long ?givenLong .
 FILTER((?lat-?givenLat)<"0.1"^^xsd:float && 
        (?lat-?givenLat)>"-0.1"^^xsd:float && 
        (?long-?givenLong)<"0.1"^^xsd:float  && 
        (?long-?givenLong)>"-0.1"^^xsd:float ) 
 ?user bot:posts ?t2 . 
 FILTER(?t1!=?t2) 
 ?t2 bot:talksAboutPositively ?nextPoi . 
 FILTER(f:talksAboutPositivelyWithProbability(?user,?nextPoi)<1)
 ?nextPoi a bot:NamedPlace ;
          geo:lat ?nextPoiLat ;
          geo:long ?nextPoiLong  .
 FILTER((?nextPoiLat-?givenLat)<"0.1"^^xsd:float &&
        (?nextPoiLat-?givenLat)>"-0.1"^^xsd:float &&
        (?nextPoiLong-?givenLong)<"0.1"^^xsd:float  &&
        (?nextPoiLong-?givenLong)>"-0.1"^^xsd:float )
}
ORDER BY DESC(?p) 
LIMIT 10 

PROBLEMS, COMMENTS and TASKS

  • those inherited by the previous queries

SELECT ?poi (probability(<http://bottari.kr/Emanuele>,  ?poi) AS ?p)
FROM STREAM <http://bottari.kr/Emanuele/position> [10m 1m] % do we have this stream? do we need it?
WHERE {
  <http://bottari.kr/Emanuele> geo:lat ?e-lat; % the user is in a position
                               geo:long ?e-long .
  ?poi geo:lat ?poiLat; % the target poi is in another position
       geo:long ?poiLong .
  FILTER (distance(POINT(? poiLat,? poiLong), POINT(?e-lat,?e-long))<"100"^^meters) % the target poi is close to the user

  <http://bottari.kr/Emanuele> bot:post [ bot:talksPositivelyAbout ?poi ]. % the current user could tweet about that poi positively
  FILTER(probability(<http://bottari.kr/Emanuele>,  ?poi)<1) % but he hasn't done it yet (otherwise the probability would have been 1)
}
ORDER BY ?p
LIMIT 10

% SEE QUERY NUMBER '''27''' IN THE ECPLISE PROJECT
PREFIX f: <java:ext.> 
SELECT ?poi (f:talksAboutPositivelyWithProbability(data:Alice,?poi) AS ?p )
WHERE {
 data:Alice geo:lat ?givenLat ;
            geo:long ?givenLong .
 ?poi a bot:NamedPlace ;
      geo:lat ?lat ;
      geo:long ?long  .
 FILTER((?lat-?givenLat)<"0.1"^^xsd:float &&
        (?lat-?givenLat)>"-0.1"^^xsd:float &&
        (?long-?givenLong)<"0.1"^^xsd:float  &&
        (?long-?givenLong)>"-0.1"^^xsd:float )
 data:Alice bot:posts ?t . 
 ?t bot:talksAboutPositively ?poi .
 FILTER(f:talksAboutPositivelyWithProbability(data:Alice,?poi)<1)
} 
ORDER BY DESC(?p) 
LIMIT 10 

PROBLEMS, COMMENTS and TASKS

  • those inherited by the previous queries

[

Aside discussion: how to model "with probability" in RDF/SPARQL

DECISION: use custom function

]

Planning towards the review

photo-lund.JPG

(Crazy) Plan

Next Phone Call

May 25th at 10.00 CEST

LarkcProject/WP6/Communication/2011-05-11_Lund-meeting (last edited 2011-05-19 10:12:04 by ?IreneCelino)