forked from ldbc/ldbc_snb_interactive_v1_impls
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbi-1.sparql
51 lines (44 loc) · 1.8 KB
/
bi-1.sparql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX sn: <http://www.ldbc.eu/ldbc_socialnet/1.0/data/>
PREFIX snvoc: <http://www.ldbc.eu/ldbc_socialnet/1.0/vocabulary/>
PREFIX sntag: <http://www.ldbc.eu/ldbc_socialnet/1.0/tag/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbpedia: <http://dbpedia.org/resource/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT ?messageYear ?isComment ?lengthCategory ?messageCount ?averageMessageLength ?sumMessageLength ?percentageOfMessages
WHERE
{
{
SELECT ?messageYear ?isComment ?lengthCategory (COUNT(?message) AS ?messageCount) (floor(AVG(?length)) AS ?averageMessageLength) (SUM(?length) AS ?sumMessageLength)
WHERE
{
{
?message a snvoc:Comment .
BIND( true AS ?isComment)
} UNION {
?message a snvoc:Post .
BIND( false AS ?isComment)
} .
?message snvoc:length ?length .
?message snvoc:creationDate ?creationDate .
FILTER (?creationDate < $date) .
BIND( year(?creationDate) AS ?messageYear) .
BIND( IF (?length < 40, 0, IF (?length < 80 , 1, IF(?length < 160, 2, 3))) AS ?lengthCategory)
}
GROUP BY ?messageYear ?isComment ?lengthCategory
}
{
SELECT (COUNT(?message) as ?totalMessageCount)
WHERE
{
VALUES (?type) {(snvoc:Comment) (snvoc:Post)} .
?message a ?type .
?message snvoc:creationDate ?creationDate .
FILTER (?creationDate <= $date)
}
}
BIND ( ?messageCount / ?totalMessageCount AS ?percentageOfMessages)
}
ORDER BY DESC(?messageYear) ?isComment ?lengthCategory