Beautify and maybe fix bi-10 sparql query
@@ -8,51 +8,50 @@ PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbpedia: <http://dbpedia.org/resource/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
-SELECT ?personId ?score (SUM(?friendInterestScore) AS ?friendsScore)
+SELECT ?personId (?interestScore + ?messageScore AS ?score) (SUM( ?friendInterestScore + ?friendMessageScore) AS ?friendsScore)
WHERE
{
{
- SELECT ?personId ((COUNT(?message) + MAX(?interestScore)) AS ?score)
+ SELECT ?personId (MAX(COALESCE(?innerInterestScore,0)) AS ?interestScore) (COALESCE(COUNT(?message),0) AS ?messageScore)
WHERE
{
- BIND ($tag as ?tagName)
VALUES (?type) {(snvoc:Comment) (snvoc:Post)}
- ?tag foaf:name ?tagName .
?personId a snvoc:Person .
- BIND( IF(EXISTS { ?personId snvoc:hasInterest ?tag}, 100, 0) AS ?interestScore)
{
?message a ?type .
?message snvoc:hasCreator ?personId .
?message snvoc:hasTag ?tag .
+ ?tag foaf:name $tag .
?message snvoc:creationDate ?creationDate .
- FILTER (?creationDate < $date) .
+ FILTER (?creationDate < $date^^xsd:dateTime)
}
UNION
{
- ?personId snvoc:hasInterest ?tag
+ ?personId snvoc:hasInterest/foaf:name $tag
+ BIND(100 AS ?innerInterestScore)
}
}
GROUP BY ?personId
}
+
{
- SELECT ?friend ((COUNT(?message) + MAX(?interestScore)) AS ?friendInterestScore)
+ SELECT ?friend (MAX(COALESCE(?friendInnerInterestScore,0)) AS ?friendInterestScore) (COALESCE(COUNT(?message),0) AS ?friendMessageScore)
WHERE
{
- BIND ($tag as ?tagName)
VALUES (?type) {(snvoc:Comment) (snvoc:Post)}
- ?tag foaf:name ?tagName .
?friend a snvoc:Person .
- BIND( IF(EXISTS { ?friend snvoc:hasInterest ?tag}, 100, 0) AS ?interestScore)
{
?message a ?type .
?message snvoc:hasCreator ?friend .
?message snvoc:hasTag ?tag .
+ ?tag foaf:name $tag .
?message snvoc:creationDate ?creationDate .
- FILTER (?creationDate < $date) .
+ FILTER (?creationDate < $date^^xsd:dateTime)
}
UNION
{
- ?friend snvoc:hasInterest ?tag
+ ?friend snvoc:hasInterest/foaf:name $tag
+ BIND(100 AS ?friendInnerInterestScore)
}
}
GROUP BY ?friend
@@ -65,6 +64,7 @@ WHERE
?personId snvoc:knows/snvoc:hasPerson ?friend
}
}
-GROUP BY ?personId ?score
+GROUP BY ?personId ?interestScore ?messageScore
ORDER BY DESC(?score + ?friendsScore) ?personId
LIMIT 100
+
