Giter Site home page Giter Site logo

airdrie-shotts-elections-wikipedia's Introduction

The code and queries etc here are unlikely to be updated as my process evolves. Later repos will likely have progressively different approaches and more elaborate tooling, as my habit is to try to improve at least one part of the process each time around.


Step 1: Configure config.json

All the relevant metadata now lives in config.json: ideally nothing will need tweaked after this. We need to be careful here to get the history of Wikidata IDs for the constituency correct.

Step 1: Scrape the results

bundle exec ruby scraper.rb config.json | tee wikipedia.csv

Step 2: Check for missing party IDs

xsv search -v -s party 'Q' wikipedia.csv

Scottish Independence Party missing, but can be linked to existing Wikidata item.

Ste 3: Check for missing election IDs

xsv search -v -s election 'Q' wikipedia.csv | xsv select electionLabel | uniq

Nothing missing.

Step 4: Generate possible missing person IDs

xsv search -v -s id 'Q' wikipedia.csv | xsv select name | tail +2 |
  sed -e 's/^/"/' -e 's/$/"@en/' | paste -s - |
  xargs -0 wd sparql find-candidates.js |
  jq -r '.[] | [.name, .item.value, .election.label, .constituency.label, .party.label] | @csv' |
  tee candidates.csv

Step 5: Combine Those and generate QuickStatements commands

xsv join -n --left 2 wikipedia.csv 1 candidates.csv | xsv select '10,1-8' | sed $'1i\\\nfoundid' | tee combo.csv
bundle exec ruby generate-qs.rb config.json | tee commands.qs

Then sent to QuickStatements as https://tools.wmflabs.org/editgroups/b/QSv2T/1598860670956

airdrie-shotts-elections-wikipedia's People

Contributors

tmtmtmtm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.