Giter Site home page Giter Site logo

2016-sleaford-byelection-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 meta.json

All the relevant metadata now lives in meta.json: ideally nothing will need tweaked after this.

Step 1: Scrape the results

jq -r '.wikipedia | "\(.url) \(.section)"' meta.json | xargs bundle exec ruby scraper.rb | tee wikipedia.csv

Step 2: Generate possible missing 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

The ones found look good, but there's no match for:

  • Jim Clarke
  • Mark Suffield
  • Paul Coyne
  • Ross Pepper
  • Sarah Stock
  • Victoria Ayling

Ross Pepper seems to be Ross David Pepper (Q75838735), so I've added an alias.

I can't find any of the others in Wikidata already.

Step 3: Combine Those

xsv join -n --left 2 wikipedia.csv 1 candidates.csv | xsv select '7,1-5' | sed $'1i\\\nfoundid' | tee combo.csv

Step 4: Generate QuickStatements commands

bundle exec ruby generate-qs.rb meta.json | tee commands.qs

Then sent to QuickStatements as https://editgroups.toolforge.org/b/QSv2T/1597077061951/

Step 5: Generate reciprocal 'candidacy' statements

SELECT ?person ?personLabel ?election ?electionLabel
WHERE {
  ?election wdt:P31 wd:Q7864918 ; wdt:P726 ?person.
  MINUS { ?person wdt:P3602 ?election }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
wd sparql mirror-candidacy-to-person.rq |
  jq -r '.[] | "\(.person.value)\tP3602\t\(.election.value)\tS3452\t\(.election.value)"' |
  tee >(pbcopy)

-> QuickStatements as https://tools.wmflabs.org/editgroups/b/QSv2T/1597083742928

2016-sleaford-byelection-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.