Skip to content

Commit

Permalink
script for issue datasets#53
Browse files Browse the repository at this point in the history
  • Loading branch information
ppKrauss committed Aug 3, 2018
1 parent 5b645f4 commit e674d70
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scripts/wd_countries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## retrieving Wikidata dataset by SparQL:
curl -o wd_countries.csv -G 'https://query.wikidata.org/sparql' \
--header "Accept: text/csv" \
--data-urlencode query='
SELECT DISTINCT (?simple_value AS ?iso2_code) ?wd_id
WHERE {
?item p:P297 ?statement .
?statement ps:P297 ?simple_value .
OPTIONAL { ?statement pq:P582 ?qualifier . }
FILTER ( !bound(?qualifier) )
BIND ( strafter(str(?item), str(wd:)) AS ?wd_id ).
} ORDER BY ?iso2_code
'
# Eliminate duplication (confusion with kingdoms and territories)
# in the future we can use "P31 Q417175" to eliminate doublets of kingdows, but "territory vs nation" need some check.
# so, filtering invalid doublets and saving with same name:
grep -v 'Q756617\|Q29999\|Q29999' wd_countries.csv | sponge wd_countries.csv

0 comments on commit e674d70

Please sign in to comment.