This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'csv' | |
file = ARGV.first or raise "Need a filename" | |
json = JSON.parse(File.read(file)) | |
puts json.map { |i| i['stances'].map { |bloc, s| [ i['id'], bloc, s['score'] ].to_csv } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'pry' | |
require 'scraped' | |
require 'wikidata/fetcher' | |
INSTANCE_OF = 'P31' | |
PPE = 'Q7185370' | |
PSE = 'Q28333164' | |
PHE = 'Q28649370' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POSITION_HELD = 'P39' | |
START_DATE = 'P580' | |
CONSTITUENCY = 'P768' | |
PARTY = 'P4100' | |
ELECTED_IN = 'P2715' | |
SOURCE = 'S143' | |
TWFY = 'Q7783633' | |
TERM_MEMBERSHIP = 'Q30524710' # Member of the 57th Parliament of the UK | |
ELECTION = 'Q25052149' # GE 2017 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name | wikidata | |
---|---|---|
Aadu Must | Q12358062 | |
Aet Maatee | Q16407380 | |
Ain Lutsepp | Q12358429 | |
Aivar Kokk | Q13608089 | |
Aivar Sõerd | Q12358481 | |
Alar Nääme | Q28845703 | |
Andre Sepp | Q16404500 | |
Andrei Novikov | Q16405149 | |
Andres Ammas | Q20528366 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
# frozen_string_literal: true | |
require 'pry' | |
require 'json' | |
require 'rest-client' | |
WIKIDATA_SPARQL_URL = 'https://query.wikidata.org/sparql' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env ruby | |
require 'csv' | |
require 'rest-client' | |
#----------------------------------------------------------------------- | |
# Find all Memberships of the Romanian Chamber of Deputies with a start | |
# time after December 2016 and add a 2016-20 term qualifier if missing. | |
# | |
# The output of this can then be passed to PositionStatements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env ruby | |
require 'csv' | |
require 'rest-client' | |
#--------------------------------------------------------------------------- | |
# Find all Memberships of the 2016-20 with no P4100 qualifier and add it | |
# from data on the Wikipedia members list page: | |
# https://ro.wikipedia.org/wiki/Legislatura_2016-2020_(Camera_Deputaților) | |
# as scraped at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env ruby | |
require 'csv' | |
require 'rest-client' | |
#--------------------------------------------------------------------------- | |
# Find all P4100s from the ALDE disambiguation item to the proper one | |
#--------------------------------------------------------------------------- | |
WIKIDATA_SPARQL_URL = 'https://query.wikidata.org/sparql' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env ruby | |
require 'csv' | |
require 'rest-client' | |
WIKIDATA_SPARQL_URL = 'https://query.wikidata.org/sparql' | |
def sparql(query) | |
result = RestClient.get WIKIDATA_SPARQL_URL, accept: 'text/csv', params: { query: query } | |
CSV.parse(result.body, headers: true, header_converters: :symbol) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env ruby | |
# frozen_string_literal: true | |
require 'csv' | |
require 'pry' | |
require 'rest-client' | |
#--------------------------------------------------------------------------- | |
# Find all members of the 37th Eduskunta with no P4100 (parliamentary group) | |
# and add one from |
OlderNewer