diff --git a/queries/tabular_queries.sparql b/queries/tabular_queries.sparql index 28311fc117..0a6a45925f 100644 --- a/queries/tabular_queries.sparql +++ b/queries/tabular_queries.sparql @@ -3,6 +3,11 @@ # people, places entity labels are concatenated # replace ?subject to get an specific biography + + + +## ======================= Version 0.1 includes lat and long, works only for meetups with one place + prefix mtp: prefix rdf: prefix rdfs: @@ -34,3 +39,77 @@ where } group by ?s ?evidence_text ?purpose ?time_expression_URI ?lat ?long + + +## ======================= Version 0.2 + +## concatenate the place name when more than one, does not include lat and long +prefix mtp: +prefix rdf: +prefix rdfs: +prefix geo: + +select ?s ?evidence_text ?purpose +(GROUP_CONCAT( DISTINCT ?participant; separator=", " ) as ?participants_URI ) +(GROUP_CONCAT( DISTINCT ?participant_label; separator=", " ) as ?participants_label ) +(GROUP_CONCAT( DISTINCT ?location_uri; separator=", " ) as ?locations_URI ) +(GROUP_CONCAT( DISTINCT ?location_label; separator=", " ) as ?locations_label ) +( MIN (?time_expression ) AS ?time_expression_URI ) +from +where +{ VALUES ?subject { } + ?s rdf:type mtp:Meetup ; + mtp:hasSubject ?subject ; + mtp:hasParticipant ?participant ; + mtp:happensAt ?time_expression ; + mtp:hasAPurpose ?purpose_uri ; + mtp:hasEvidenceText ?evidence_text ; + mtp:hasPlace ?location_uri . + FILTER (!regex (str(?participant), str(?subject) ) ) . + ?participant rdfs:label ?participant_label . + ?location_uri rdfs:label ?location_label . + ?purpose_uri rdfs:label ?purpose +} + +group by ?s ?evidence_text ?purpose ?time_expression_URI + +## ======================= Version 0.3 +## (a) A query that retrieves only one place and the coordinates (no matter if there is two or more places) +## first place (when more than one), includes coordinates + +prefix mtp: +prefix rdf: +prefix rdfs: +prefix geo: + +select DISTINCT ?s ?evidence_text ?purpose +(GROUP_CONCAT( DISTINCT ?participant; separator=", " ) as ?participants_URI ) +(GROUP_CONCAT( DISTINCT ?participant_label; separator=", " ) as ?participants_label ) +( MIN (?time_expression ) AS ?time_expression_URI ) +?location_uri ?location_label ?lat ?long +from +where { + VALUES ?subject { } + ?s rdf:type mtp:Meetup ; + mtp:hasSubject ?subject ; + mtp:hasParticipant ?participant ; + mtp:happensAt ?time_expression ; + mtp:hasAPurpose ?purpose_uri ; + mtp:hasEvidenceText ?evidence_text ; + mtp:hasPlace ?location_uri . + { + SELECT ?s (MIN (?location ) AS ?location_uri) WHERE { + VALUES ?subject { } + ?s mtp:hasPlace ?location ; + mtp:hasSubject ?subject . + }GROUP BY ?s + } + . + FILTER (!regex (str(?participant), str(?subject) ) ) . + ?participant rdfs:label ?participant_label . + ?location_uri rdfs:label ?location_label ; + geo:lat ?lat ; + geo:long ?long . + ?purpose_uri rdfs:label ?purpose +} +group by ?s ?evidence_text ?purpose ?time_expression_URI ?lat ?long ?location_label ?location_uri diff --git a/queries/top-entities.sparql b/queries/top-entities.sparql new file mode 100644 index 0000000000..099335f795 --- /dev/null +++ b/queries/top-entities.sparql @@ -0,0 +1,82 @@ +# ========================= TOP PEOPLE + +prefix mtp: + +select ( count( ?participant) as ?num_people ) ?participant +from +where +{ VALUES ?subject { } + ?s rdf:type mtp:Meetup ; + mtp:hasSubject ?subject ; + mtp:hasParticipant ?participant . + FILTER (!regex (str(?participant), str(?subject) ) ) . +} + +GROUP BY ?participant +ORDER BY DESC(?num_people) ?participant +LIMIT 2 + +# ========================= TOP PLACES +prefix mtp: +select ( count( ?place) as ?number_place ) ?place +from +where +{ ?s rdf:type mtp:Meetup ; + mtp:hasSubject ; + mtp:hasPlace ?place . +} + +GROUP BY ?place +ORDER BY DESC(?number_place) +LIMIT 2 + + +# ========================= TOP TIME + + + +# ========================= TOP THEMES +## ======================= Version 0.2 concatenate the place name when more than one, does not include lat and long +prefix mtp: +prefix rdf: +prefix rdfs: +prefix geo: + +select ?s ?evidence_text ?purpose +(GROUP_CONCAT( DISTINCT ?participant; separator=", " ) as ?participants_URI ) +(GROUP_CONCAT( DISTINCT ?participant_label; separator=", " ) as ?participants_label ) +(GROUP_CONCAT( DISTINCT ?location_uri; separator=", " ) as ?locations_URI ) +(GROUP_CONCAT( DISTINCT ?location_label; separator=", " ) as ?locations_label ) +( MIN (?time_expression ) AS ?time_expression_URI ) +from +where +{ VALUES ?subject { } + ?s rdf:type mtp:Meetup ; + mtp:hasSubject ?subject ; + mtp:hasParticipant ?participant ; + mtp:happensAt ?time_expression ; + mtp:hasAPurpose ?purpose_uri ; + mtp:hasEvidenceText ?evidence_text ; + mtp:hasPlace ?location_uri . + FILTER (!regex (str(?participant), str(?subject) ) ) . + ?participant rdfs:label ?participant_label . + ?location_uri rdfs:label ?location_label . + ?purpose_uri rdfs:label ?purpose +} + +group by ?s ?evidence_text ?purpose ?time_expression_URI + + +## ======================= Version 0.1 includes lat and long, works only for meetups with one place +prefix mtp: +select ( count( ?meetupType) as ?number_mt ) ?meetupType +from +where +{ ?s rdf:type mtp:Meetup ; + mtp:hasSubject ; + mtp:hasAPurpose ?meetupType . + #?meetupType rdfs:label ?meetupTypeName . +} + +GROUP BY ?meetupType +ORDER BY DESC(?number_mt) \ No newline at end of file