everypolitician / everypolitician-popolo

Ruby gem for interacting with EveryPolitician data for a legislature
MIT License
7 stars 4 forks source link

add real methods to area #93

Closed struan closed 8 years ago

struan commented 8 years ago

This replaces the autogenerated methods on Area with real methods.

It also adds a wikidata method.

Part of #54

struan commented 8 years ago

Sadly we don't actually have any data where there are areas both with and without identifiers:

d = Everypolitician.countries
f = d.map { |c| c.legislatures.map { |l| l.directory  + '/' + 'ep-popolo-v1.0.json } }.flatten

f.each { |file|
  ep = Everypolitician::Popolo.read(file)
  area_with = ep.areas.select { |a| a.identifiers.count > 0 } 
  area_without = ep.areas.select { |a| a.identifiers.count == 0 } 
  puts file if area_with.count > 0 && area_without.count > 0 
}

produces zero results. ( assuming you are running it in the parent directory of a local copy of ep-data.

tmtmtmtm commented 8 years ago

Ah, it's even worse than that. Estonia seems to the only place where we even have identifiers for Areas at all yet:

Everypolitician.countries.flat_map(&:legislatures).each do |l|
  ep = Everypolitician::Popolo.read(l.raw_data[:popolo])
  area_without, area_with = ep.areas.partition { |a| a.identifiers.count.zero? }
  puts "#{l.country.name} #{l.name}: With #{area_with.count} / Without #{area_without.count}" if area_with.count > 0
end

(from the base dir — though l.raw_data[:popolo] is a bit nasty there: https://github.com/everypolitician/everypolitician-ruby/issues/59 opened)

tmtmtmtm commented 8 years ago

I don't see why the test needs to only run against a single legislature though? Presumably the 'with' test could use Estonia, and the 'without' test Turkey?

struan commented 8 years ago

er, yes, yes, it could use more than one file.