diff --git a/UseCase/EP/pargov.R b/UseCase/EP/pargov.R new file mode 100644 index 0000000..3cb98b9 --- /dev/null +++ b/UseCase/EP/pargov.R @@ -0,0 +1,11 @@ +library(dplyr) +library(lubridate) + +read.csv("http://www.parlgov.org/static/stable/2015/view_party.csv") -> partie +read.csv("http://www.parlgov.org/static/stable/2015/view_election.csv") -> wybory + +wybory %>% + filter(country_id == 74 & election_type == "ep") %>% + count(rok = year(election_date), partia = party_name_short) %>% + count(rok) + diff --git a/UseCase/EP/queries.R b/UseCase/EP/queries.R new file mode 100644 index 0000000..ae9f08f --- /dev/null +++ b/UseCase/EP/queries.R @@ -0,0 +1,44 @@ +# install.packages("SPARQL") +library(SPARQL) + +endpoint <- "http://linkedpolitics.ops.few.vu.nl/sparql/" + +q <- "SELECT ?text ?date ?agendaitemnr ?speechnr +WHERE { +?sessionday rdf:type lpv_eu:SessionDay . +?sessionday dcterms:date ?date. +?sessionday dcterms:hasPart ?agendaitem. +?agendaitem dcterms:hasPart ?speech. + +?agendaitem lpv:number ?agendaitemnr. +?speech lpv:number ?speechnr. +?speech lpv:spokenText ?text. +FILTER ( ?date >= '2009-05-06'^^xsd:date && ?date <= '2010-05-06'^^xsd:date ) +FILTER(langMatches(lang(?text), 'en')) + +} ORDER BY ?date ?agendaitemnr ?speechnr LIMIT 100" +res <- SPARQL(endpoint, q)$results +res$date <- as.Date(as.POSIXct(res$date, origin = "1970-01-01")) + + +q <- "SELECT ?partyname (COUNT(DISTINCT ?speech) AS ?speechno) +WHERE { + dcterms:hasPart ?speech. +?speech lpv:spokenAs ?function. +?function lpv:institution ?party. +?party rdf:type lpv:EUParty. +?party lpv:acronym ?partyname. +} GROUP BY ?partyname" +res2 <- SPARQL(endpoint, q)$results + + + +q <- "SELECT ?partyname (COUNT(DISTINCT ?speech) AS ?speechno) +WHERE { +?ai rdf:type . +?ai dcterms:hasPart ?speech. +?speech lpv:speaker ?speaker. +?speaker lpv:countryOfRepresentation ?country. +?country rdfs:label ?label. +filter(?label='Poland'@en)}" +res3 <- SPARQL(endpoint, q)$results