codeforjapan / codeforelection

衆院選2017候補者データベース作成プロジェクト This repo will be archived 🗄️ in the future
MIT License
32 stars 6 forks source link

GrayDB から Wikidata へのインポートを実施 #35

Closed halsk closed 6 years ago

halsk commented 6 years ago

How to use import tool of Wikidata

mySociety から教えて貰った、インポートツールの使い方です。

The main tool you can use to create Wikidata items is QuickStatements.

There are two versions of this. The old one is largely deprecated now, so you'll want to use the one at https://tools.wmflabs.org/quickstatements/

However, the instructions for it are still only on the old one! — https://tools.wmflabs.org/wikidata-todo/quick_statements.php Once you've created the statements for it, you select the "Import Commands" > "Version 1 format" from the header bar in the new version (it's quite well hidden!)

For creating new items, or adding basic statements to existing items, everything should work smoothly, but you should beware that if you use it for adding P39 (position held) records to existing items, it doesn't work if someone has held the same position more than once. Unfortunately that's very common with political data, where it's very likely that there will be a large number of people elected as a Q17506823 (member of the House of Representatives of Japan) in the 48th Term, who already have a P39: Q17506823 record for the 47th Term.

To help with that, we've developed a bot called PositionStatements that takes input in exactly the same format as QuickStatements, but adds an entirely new P39 record each time, rather than combining them all into one as QS does. There's no web interface to that yet, but you can either try to get the bot running yourselves locally (it's a Python script, linked from https://www.wikidata.org/wiki/Wikidata:Requests_for_permissions/Bot/PositionStatements_Bot), or you can send us a TSV file of commands, and we can run it on behalf of a Wikidata account of your choosing.

If you have any questions about either QuickStatements or PositionStatements, feel free to ask. It can be a bit confusing at first, but once you get the hang of it, it's incredibly powerful.

Do you think you'll be able to use these tools to add all the information we need directly into Wikidata?

http://tinyurl.com/yabzpkde is an example of a SPARQL query to get a list of members of the outgoing (47th) House of Representatives. That data is still quite far from complete, but it should be enough to give you the basic idea (and perhaps to practice with the tools), and it can easily be adjusted to find the members of the 48th after the election: http://tinyurl.com/ybvdcw66

Similarly, Wikidata's current understanding of who the governors of each prefecture is: http://tinyurl.com/ya57emlx — again, it would be ideal for us if you could correct any errors or omissions directly there.

higa4 commented 6 years ago

GrayDB(google spread sheet)上でwikidataを参照できるプラグインです。 https://chrome.google.com/webstore/detail/wikipedia-and-wikidata-to/aiilcelhmpllcgkhhpifagfehbddkdfp?utm_source=permalink

takahashim commented 6 years ago

今日の作業の報告です。 GrayDB内にある、Wikidata未登録の候補者についてはこちらのツールを使って一括投入しました。Wikidata IDをGrayDBに戻す作業はまだのものが多数(300件から400件程度)あります。 今後の投入作業としては、各候補者の公認政党についてはこのツール(と投入用バッチ生成スクリプト)で一括更新できるように思います。

takahashim commented 6 years ago

GrayDB内の候補者データについて、現在登録されているGrayDBId 1048までは全てWikidata IDを付番しました。

takahashim commented 6 years ago

https://github.com/takahashim/cfej_import_wikidata 未登録者のインポートコマンド生成に使ったプロジェクトを整理してこちらに置いておきました。OAuth2のclient_secret.jsonを取得するのが面倒くさいです…(が、Google Spreadsheets APIはそういう仕様なんでしょうがない)。

higa4 commented 6 years ago

おくればせながらQuickStatementsの使い方説明文書があったのではっておきます。 https://www.wikidata.org/wiki/Help:QuickStatements いちばん下の「CSV to quick_statements 」というツールを使えば楽ができるかもしれない。

nyampire commented 6 years ago

以下で再作業のスレッドがたっているので、こちらクローズとしたく。

https://github.com/codeforjapan/codeforelection/issues/61