Skip to content

Commit

Permalink
Change Wikidata fetching to be by P39, not P463
Browse files Browse the repository at this point in the history
Now that there's a "legislative term" modifier for P39, we're using that
everywhere instead of being a member of a Term. I've migrated each
person on the old approach to the new one, so we can now switch the
query to fetch the more correct way.
  • Loading branch information
tmtmtmtm committed Mar 8, 2017
1 parent a4ddc2f commit 87c0c94
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions scraper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@
11 => WikiData::Category.new('Categoría:Diputados_de_la_XI_Legislatura_de_España', 'es').member_titles,
}

sparq = 'SELECT ?item WHERE { ?item wdt:P463 wd:Q%s . }'
ids = {
10 => EveryPolitician::Wikidata.sparql(sparq % 2498034),
11 => EveryPolitician::Wikidata.sparql(sparq % 21857364),
}
sparq = <<EOQ
SELECT ?item
WHERE {
VALUES ?term { wd:Q2498034 wd:Q21857364 }
?item p:P39 ?position_statement .
?position_statement ps:P39 wd:Q18171345 ;
pq:P2937 ?term .
}
EOQ

ids = EveryPolitician::Wikidata.sparql(sparq)

EveryPolitician::Wikidata.scrape_wikidata(ids: ids.values.inject(&:|), names: { es: names.values.inject(&:|) })
EveryPolitician::Wikidata.scrape_wikidata(ids: ids, names: { es: names.values.inject(&:|) })

0 comments on commit 87c0c94

Please sign in to comment.