sapor 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/create_installation_package.sh +1 -1
- data/bin/install.sh +1 -1
- data/bin/sapor.rb +1 -1
- data/bin/sapor.sh +1 -1
- data/data/hu/hungary-2014.txt +1 -1
- data/data/hu/hungary_2014_screen_scraper.rb +1 -1
- data/data/hu/hungary_2014_to_psv.rb +2 -2
- data/data/ie/2016-04-28_general-election-2016-candidate-details-csv_en.csv +552 -0
- data/data/ie/ireland_2016_to_psv.rb +138 -0
- data/data/no/2020-01-01_partifordeling_1_st_2017.csv +335 -0
- data/data/no/norway_2017_to_psv.rb +61 -0
- data/data/pl/poland_2015_to_psv.rb +2 -2
- data/data/pl/poland_2015_to_psv_with_ko_and_rsw.rb +2 -2
- data/data/pl/poland_2015_to_psv_with_ko_konf_kp_l_and_zp.rb +2 -2
- data/data/pl/poland_2015_to_psv_with_ko_sld_and_wi.rb +2 -2
- data/data/pl/poland_2015_to_psv_with_sld.rb +2 -2
- data/data/pl/poland_2015_to_psv_with_sld_and_wi.rb +2 -2
- data/data/uk/united_kingdom_2015_to_psv.rb +2 -2
- data/data/uk/united_kingdom_2017_to_psv.rb +2 -2
- data/data/uk/united_kingdom_2017_to_psv_with_brexit_and_chuk.rb +2 -2
- data/data/uk/united_kingdom_2017_to_psv_with_tig.rb +2 -2
- data/lib/sapor.rb +3 -3
- data/lib/sapor/binomials_cache.rb +1 -1
- data/lib/sapor/combinations_distribution.rb +1 -1
- data/lib/sapor/denominators.rb +1 -1
- data/lib/sapor/dichotomies.rb +1 -1
- data/lib/sapor/dichotomy.rb +1 -1
- data/lib/sapor/first_past_the_post.rb +1 -1
- data/lib/sapor/largest_remainder.rb +1 -1
- data/lib/sapor/log4r_logger.rb +1 -1
- data/lib/sapor/log_facade.rb +1 -1
- data/lib/sapor/many_past_the_post.rb +113 -0
- data/lib/sapor/multi_district_leveled_proportional.rb +1 -1
- data/lib/sapor/multi_district_proportional.rb +1 -1
- data/lib/sapor/multi_district_variable_threshold_proportional.rb +1 -1
- data/lib/sapor/number_formatter.rb +1 -1
- data/lib/sapor/options.rb +1 -1
- data/lib/sapor/poll.rb +12 -14
- data/lib/sapor/polychotomy.rb +1 -1
- data/lib/sapor/pseudorandom_multirange_enumerator.rb +1 -1
- data/lib/sapor/referendum_polychotomy.rb +1 -1
- data/lib/sapor/regional_data/area.rb +28 -10
- data/lib/sapor/regional_data/austria.rb +1 -1
- data/lib/sapor/regional_data/belgium-brussels-2014.psv +1 -1
- data/lib/sapor/regional_data/belgium-brussels-20190526.psv +1 -1
- data/lib/sapor/regional_data/belgium-flanders-2014.psv +1 -1
- data/lib/sapor/regional_data/belgium-flanders-20190526.psv +1 -1
- data/lib/sapor/regional_data/belgium-wallonia-2014.psv +1 -1
- data/lib/sapor/regional_data/belgium-wallonia-20190526.psv +1 -1
- data/lib/sapor/regional_data/belgium.rb +1 -1
- data/lib/sapor/regional_data/belgium_brussels.rb +1 -1
- data/lib/sapor/regional_data/belgium_flanders.rb +1 -1
- data/lib/sapor/regional_data/belgium_wallonia.rb +1 -1
- data/lib/sapor/regional_data/catalonia-2012-2015.psv +1 -1
- data/lib/sapor/regional_data/catalonia-2012.psv +1 -1
- data/lib/sapor/regional_data/catalonia-2015-jxcat.psv +1 -1
- data/lib/sapor/regional_data/catalonia-2015-no-jxsi.psv +1 -1
- data/lib/sapor/regional_data/catalonia-2015.psv +1 -1
- data/lib/sapor/regional_data/catalonia-20171221-with-vox.psv +67 -0
- data/lib/sapor/regional_data/catalonia-20171221.psv +61 -0
- data/lib/sapor/regional_data/catalonia.rb +57 -29
- data/lib/sapor/regional_data/denmark-20150618-with-e-and-p.psv +1 -1
- data/lib/sapor/regional_data/denmark-20150618-with-e.psv +1 -1
- data/lib/sapor/regional_data/denmark-20150618-with-p.psv +1 -1
- data/lib/sapor/regional_data/denmark-20150618.psv +1 -1
- data/lib/sapor/regional_data/denmark.rb +1 -1
- data/lib/sapor/regional_data/denmark_with_e.rb +1 -1
- data/lib/sapor/regional_data/denmark_with_e_and_p.rb +1 -1
- data/lib/sapor/regional_data/denmark_with_p.rb +1 -1
- data/lib/sapor/regional_data/estonia.rb +1 -1
- data/lib/sapor/regional_data/european-union-great-britain-20140522-brexit-chuk.psv +1 -1
- data/lib/sapor/regional_data/european-union-great-britain-20140522.psv +1 -1
- data/lib/sapor/regional_data/european-union-great-britain-20190523.psv +1 -1
- data/lib/sapor/regional_data/european-union-ireland-2014-ia-ri-sd.psv +1 -1
- data/lib/sapor/regional_data/european-union-ireland-2014-ia-sd.psv +1 -1
- data/lib/sapor/regional_data/european-union-ireland-2014-ia.psv +1 -1
- data/lib/sapor/regional_data/european-union-ireland-2014-sd.psv +1 -1
- data/lib/sapor/regional_data/european-union-ireland-2014.psv +1 -1
- data/lib/sapor/regional_data/european-union-ireland-20190524-ia.psv +1 -1
- data/lib/sapor/regional_data/european-union-ireland-20190524.psv +1 -1
- data/lib/sapor/regional_data/european_union_27_austria.rb +1 -1
- data/lib/sapor/regional_data/european_union_27_croatia.rb +4 -2
- data/lib/sapor/regional_data/european_union_27_denmark.rb +1 -1
- data/lib/sapor/regional_data/european_union_27_estonia.rb +1 -1
- data/lib/sapor/regional_data/european_union_27_finland.rb +1 -1
- data/lib/sapor/regional_data/european_union_27_france.rb +1 -1
- data/lib/sapor/regional_data/european_union_27_ireland.rb +1 -1
- data/lib/sapor/regional_data/european_union_27_ireland_with_ia.rb +1 -1
- data/lib/sapor/regional_data/european_union_27_italy.rb +1 -1
- data/lib/sapor/regional_data/european_union_27_netherlands.rb +1 -1
- data/lib/sapor/regional_data/european_union_27_poland.rb +1 -1
- data/lib/sapor/regional_data/european_union_27_romania.rb +1 -1
- data/lib/sapor/regional_data/european_union_27_slovakia.rb +1 -1
- data/lib/sapor/regional_data/european_union_27_spain.rb +1 -1
- data/lib/sapor/regional_data/european_union_27_sweden.rb +1 -1
- data/lib/sapor/regional_data/european_union_austria.rb +1 -1
- data/lib/sapor/regional_data/european_union_bulgaria.rb +1 -1
- data/lib/sapor/regional_data/european_union_croatia.rb +4 -2
- data/lib/sapor/regional_data/european_union_cyprus.rb +1 -1
- data/lib/sapor/regional_data/european_union_czech_republic.rb +1 -1
- data/lib/sapor/regional_data/european_union_denmark.rb +1 -1
- data/lib/sapor/regional_data/european_union_estonia.rb +1 -1
- data/lib/sapor/regional_data/european_union_finland.rb +1 -1
- data/lib/sapor/regional_data/european_union_flanders.rb +1 -1
- data/lib/sapor/regional_data/european_union_france.rb +1 -1
- data/lib/sapor/regional_data/european_union_french_community_of_belgium.rb +1 -1
- data/lib/sapor/regional_data/european_union_germany.rb +1 -1
- data/lib/sapor/regional_data/european_union_great_britain.rb +1 -1
- data/lib/sapor/regional_data/european_union_greece.rb +1 -1
- data/lib/sapor/regional_data/european_union_hungary.rb +1 -1
- data/lib/sapor/regional_data/european_union_ireland.rb +1 -1
- data/lib/sapor/regional_data/european_union_ireland_with_ia.rb +1 -1
- data/lib/sapor/regional_data/european_union_italy.rb +1 -1
- data/lib/sapor/regional_data/european_union_latvia.rb +1 -1
- data/lib/sapor/regional_data/european_union_lithuania.rb +1 -1
- data/lib/sapor/regional_data/european_union_luxembourg.rb +1 -1
- data/lib/sapor/regional_data/european_union_malta.rb +1 -1
- data/lib/sapor/regional_data/european_union_netherlands.rb +1 -1
- data/lib/sapor/regional_data/european_union_northern_ireland.rb +1 -1
- data/lib/sapor/regional_data/european_union_poland.rb +1 -1
- data/lib/sapor/regional_data/european_union_portugal.rb +1 -1
- data/lib/sapor/regional_data/european_union_romania.rb +1 -1
- data/lib/sapor/regional_data/european_union_slovakia.rb +1 -1
- data/lib/sapor/regional_data/european_union_slovenia.rb +1 -1
- data/lib/sapor/regional_data/european_union_spain.rb +1 -1
- data/lib/sapor/regional_data/european_union_sweden.rb +1 -1
- data/lib/sapor/regional_data/finland-20150419-with-sin.psv +1 -1
- data/lib/sapor/regional_data/finland-20150419.psv +1 -1
- data/lib/sapor/regional_data/finland.rb +1 -1
- data/lib/sapor/regional_data/finland_with_sin.rb +1 -1
- data/lib/sapor/regional_data/flanders-2014.psv +1 -1
- data/lib/sapor/regional_data/flanders-20190526.psv +1 -1
- data/lib/sapor/regional_data/flanders.rb +1 -1
- data/lib/sapor/regional_data/france.rb +1 -1
- data/lib/sapor/regional_data/greece.rb +1 -1
- data/lib/sapor/regional_data/hungary-2014.psv +1 -1
- data/lib/sapor/regional_data/hungary.rb +1 -1
- data/lib/sapor/regional_data/iceland-20161029-midflokkurinn.psv +1 -1
- data/lib/sapor/regional_data/iceland-20161029.psv +1 -1
- data/lib/sapor/regional_data/iceland-20171028-with-j.psv +94 -0
- data/lib/sapor/regional_data/iceland-20171028.psv +1 -1
- data/lib/sapor/regional_data/iceland.rb +32 -16
- data/lib/sapor/regional_data/ireland-20160226-2020-candidates.psv +322 -0
- data/lib/sapor/regional_data/ireland-20160226-2020.psv +344 -0
- data/lib/sapor/regional_data/ireland-20160226.psv +348 -0
- data/lib/sapor/regional_data/ireland.rb +165 -0
- data/lib/sapor/regional_data/latvia-20141004-kpv-p-par.psv +1 -1
- data/lib/sapor/regional_data/latvia-20141004-kpv-par.psv +1 -1
- data/lib/sapor/regional_data/latvia-20141004-kpv.psv +1 -1
- data/lib/sapor/regional_data/latvia-20141004.psv +1 -1
- data/lib/sapor/regional_data/latvia-20181006.psv +1 -1
- data/lib/sapor/regional_data/latvia.rb +1 -1
- data/lib/sapor/regional_data/luxembourg-20131020.psv +1 -1
- data/lib/sapor/regional_data/luxembourg-20181014.psv +1 -1
- data/lib/sapor/regional_data/luxembourg.rb +1 -1
- data/lib/sapor/regional_data/netherlands.rb +1 -1
- data/lib/sapor/regional_data/norway-20170911.psv +331 -0
- data/lib/sapor/regional_data/norway.rb +44 -339
- data/lib/sapor/regional_data/norwegian_municipality.rb +1 -1
- data/lib/sapor/regional_data/poland-20151025-with-ko-and-l-without-n-po-r-and-zl.psv +1 -1
- data/lib/sapor/regional_data/poland-20151025-with-ko-konf-kp-l-and-zp-without-k-k15-n-pis-po-psl-r-and-zl.psv +1 -1
- data/lib/sapor/regional_data/poland-20151025-with-ko-sld-and-wi-without-n-po-and-zl.psv +1 -1
- data/lib/sapor/regional_data/poland-20151025-with-sld-and-wi-without-zl.psv +1 -1
- data/lib/sapor/regional_data/poland-20151025-with-sld-without-zl.psv +1 -1
- data/lib/sapor/regional_data/poland-20151025.psv +1 -1
- data/lib/sapor/regional_data/poland.rb +1 -1
- data/lib/sapor/regional_data/poland_with_ko_and_l_without_n_po_r_and_zl.rb +1 -1
- data/lib/sapor/regional_data/poland_with_ko_konf_kp_l_and_zp_without_k_k15_n_pis_po_psl_r_and_zl.rb +1 -1
- data/lib/sapor/regional_data/poland_with_ko_sld_and_wi_without_n_po_and_zl.rb +1 -1
- data/lib/sapor/regional_data/poland_with_sld_and_wi_without_zl.rb +1 -1
- data/lib/sapor/regional_data/poland_with_sld_without_zl.rb +1 -1
- data/lib/sapor/regional_data/portugal-20151004-with-a-and-ch-without-paf.psv +1 -1
- data/lib/sapor/regional_data/portugal-20151004-with-a-and-il-without-paf.psv +1 -1
- data/lib/sapor/regional_data/portugal-20151004-with-a-ch-and-il-without-paf.psv +1 -1
- data/lib/sapor/regional_data/portugal-20151004-with-a-without-paf.psv +1 -1
- data/lib/sapor/regional_data/portugal-20151004-with-ch-and-il-without-paf.psv +1 -1
- data/lib/sapor/regional_data/portugal-20151004-without-paf.psv +1 -1
- data/lib/sapor/regional_data/portugal-20151004.psv +1 -1
- data/lib/sapor/regional_data/portugal.rb +1 -1
- data/lib/sapor/regional_data/portugal_with_a_and_ch_without_paf.rb +1 -1
- data/lib/sapor/regional_data/portugal_with_a_and_il_without_paf.rb +1 -1
- data/lib/sapor/regional_data/portugal_with_a_ch_and_il_without_paf.rb +1 -1
- data/lib/sapor/regional_data/portugal_with_a_without_paf.rb +1 -1
- data/lib/sapor/regional_data/portugal_with_ch_and_il_without_paf.rb +1 -1
- data/lib/sapor/regional_data/portugal_without_paf.rb +1 -1
- data/lib/sapor/regional_data/slovakia.rb +1 -1
- data/lib/sapor/regional_data/slovenia.rb +1 -1
- data/lib/sapor/regional_data/spain-20160626.psv +1 -1
- data/lib/sapor/regional_data/spain.rb +1 -1
- data/lib/sapor/regional_data/sweden.rb +1 -1
- data/lib/sapor/regional_data/sweden_20140914.rb +1 -1
- data/lib/sapor/regional_data/united_kingdom-2015.psv +1 -1
- data/lib/sapor/regional_data/united_kingdom-20170608-brexit-chuk.psv +1 -1
- data/lib/sapor/regional_data/united_kingdom-20170608-brexit.psv +1 -1
- data/lib/sapor/regional_data/united_kingdom-20170608-tig.psv +1 -1
- data/lib/sapor/regional_data/united_kingdom-20170608.psv +1 -1
- data/lib/sapor/regional_data/united_kingdom.rb +1 -1
- data/lib/sapor/regional_data/united_kingdom_with_brexit.rb +1 -1
- data/lib/sapor/regional_data/united_kingdom_with_brexit_and_chuk.rb +1 -1
- data/lib/sapor/regional_data/united_kingdom_with_tig.rb +1 -1
- data/lib/sapor/regional_data/utopia.rb +1 -1
- data/lib/sapor/regional_data/wallonia-2014.psv +1 -1
- data/lib/sapor/regional_data/wallonia-20190526.psv +1 -1
- data/lib/sapor/regional_data/wallonia.rb +1 -1
- data/lib/sapor/representatives_polychotomy.rb +1 -1
- data/lib/sapor/single_district_proportional.rb +1 -1
- data/sapor.gemspec +2 -2
- data/spec/integration/area_spec.rb +1 -1
- data/spec/integration/poll_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/area_spec.rb +1 -1
- data/spec/unit/austria_spec.rb +1 -1
- data/spec/unit/belgium_brussels_spec.rb +1 -1
- data/spec/unit/belgium_flanders_spec.rb +1 -1
- data/spec/unit/belgium_spec.rb +1 -1
- data/spec/unit/belgium_wallonia_spec.rb +1 -1
- data/spec/unit/binomials_cache_spec.rb +1 -1
- data/spec/unit/catalonia_spec.rb +13 -26
- data/spec/unit/catalonia_with_vox_spec.rb +62 -0
- data/spec/unit/combinations_distribution_spec.rb +1 -1
- data/spec/unit/denmark_spec.rb +1 -1
- data/spec/unit/denmark_with_e_and_p_spec.rb +1 -1
- data/spec/unit/denmark_with_e_spec.rb +1 -1
- data/spec/unit/denmark_with_p_spec.rb +1 -1
- data/spec/unit/denominators_spec.rb +1 -1
- data/spec/unit/dichotomies_spec.rb +1 -1
- data/spec/unit/dichotomy_spec.rb +1 -1
- data/spec/unit/estonia_spec.rb +1 -1
- data/spec/unit/european_union_27_austria_spec.rb +1 -1
- data/spec/unit/european_union_27_croatia_spec.rb +1 -1
- data/spec/unit/european_union_27_denmark_spec.rb +1 -1
- data/spec/unit/european_union_27_estonia_spec.rb +1 -1
- data/spec/unit/european_union_27_finland_spec.rb +1 -1
- data/spec/unit/european_union_27_france_spec.rb +1 -1
- data/spec/unit/european_union_27_ireland_spec.rb +1 -1
- data/spec/unit/european_union_27_ireland_with_ia_spec.rb +1 -1
- data/spec/unit/european_union_27_italy_spec.rb +1 -1
- data/spec/unit/european_union_27_netherlands_spec.rb +1 -1
- data/spec/unit/european_union_27_poland_spec.rb +1 -1
- data/spec/unit/european_union_27_romania_spec.rb +1 -1
- data/spec/unit/european_union_27_slovakia_spec.rb +1 -1
- data/spec/unit/european_union_27_spain_spec.rb +1 -1
- data/spec/unit/european_union_27_sweden_spec.rb +1 -1
- data/spec/unit/european_union_austria_spec.rb +1 -1
- data/spec/unit/european_union_bulgaria_spec.rb +1 -1
- data/spec/unit/european_union_croatia_spec.rb +1 -1
- data/spec/unit/european_union_cyprus_spec.rb +1 -1
- data/spec/unit/european_union_czech_republic_spec.rb +1 -1
- data/spec/unit/european_union_denmark_spec.rb +1 -1
- data/spec/unit/european_union_estonia_spec.rb +1 -1
- data/spec/unit/european_union_finland_spec.rb +1 -1
- data/spec/unit/european_union_flanders_spec.rb +1 -1
- data/spec/unit/european_union_france_spec.rb +1 -1
- data/spec/unit/european_union_french_community_of_belgium_spec.rb +1 -1
- data/spec/unit/european_union_germany_spec.rb +1 -1
- data/spec/unit/european_union_great_britain_spec.rb +1 -1
- data/spec/unit/european_union_greece_spec.rb +1 -1
- data/spec/unit/european_union_hungary_spec.rb +1 -1
- data/spec/unit/european_union_ireland_spec.rb +1 -1
- data/spec/unit/european_union_ireland_with_ia_spec.rb +1 -1
- data/spec/unit/european_union_italy_spec.rb +1 -1
- data/spec/unit/european_union_latvia_spec.rb +1 -1
- data/spec/unit/european_union_lithuania_spec.rb +1 -1
- data/spec/unit/european_union_luxembourg_spec.rb +1 -1
- data/spec/unit/european_union_malta_spec.rb +1 -1
- data/spec/unit/european_union_netherlands_spec.rb +1 -1
- data/spec/unit/european_union_northern_ireland_spec.rb +1 -1
- data/spec/unit/european_union_poland_spec.rb +1 -1
- data/spec/unit/european_union_portugal_spec.rb +1 -1
- data/spec/unit/european_union_romania_spec.rb +1 -1
- data/spec/unit/european_union_slovakia_spec.rb +1 -1
- data/spec/unit/european_union_slovenia_spec.rb +1 -1
- data/spec/unit/european_union_spain_spec.rb +1 -1
- data/spec/unit/european_union_sweden_spec.rb +1 -1
- data/spec/unit/finland_spec.rb +1 -1
- data/spec/unit/finland_with_sin_spec.rb +1 -1
- data/spec/unit/first_past_the_post_spec.rb +1 -1
- data/spec/unit/flanders_spec.rb +1 -1
- data/spec/unit/france_spec.rb +1 -1
- data/spec/unit/greece_spec.rb +1 -1
- data/spec/unit/hungary_spec.rb +1 -1
- data/spec/unit/iceland_spec.rb +1 -1
- data/spec/unit/iceland_with_j_spec.rb +58 -0
- data/spec/unit/ireland_2016_spec.rb +62 -0
- data/spec/unit/ireland_spec.rb +62 -0
- data/spec/unit/largest_remainder_spec.rb +1 -1
- data/spec/unit/latvia_spec.rb +1 -1
- data/spec/unit/luxembourg_spec.rb +1 -1
- data/spec/unit/multi_district_leveled_proportional_spec.rb +1 -1
- data/spec/unit/multi_district_proportional_spec.rb +1 -1
- data/spec/unit/netherlands_spec.rb +1 -1
- data/spec/unit/norway_spec.rb +26 -21
- data/spec/unit/norwegian_municipality_spec.rb +1 -1
- data/spec/unit/number_formatter_spec.rb +1 -1
- data/spec/unit/poland_spec.rb +1 -1
- data/spec/unit/poland_with_ko_and_l_without_n_po_r_and_zl_spec.rb +1 -1
- data/spec/unit/poland_with_ko_konf_kp_l_and_zp_without_k_k15_n_pis_po_psl_r_and_zl_spec.rb +1 -1
- data/spec/unit/poland_with_ko_sld_and_wi_without_n_po_and_zl_spec.rb +1 -1
- data/spec/unit/poland_with_sld_and_wi_without_zl_spec.rb +1 -1
- data/spec/unit/poland_with_sld_without_zl_spec.rb +1 -1
- data/spec/unit/poll_spec.rb +1 -1
- data/spec/unit/portugal_spec.rb +1 -1
- data/spec/unit/portugal_with_a_and_ch_without_paf_spec.rb +1 -1
- data/spec/unit/portugal_with_a_and_il_without_paf_spec.rb +1 -1
- data/spec/unit/portugal_with_a_ch_and_il_without_paf_spec.rb +1 -1
- data/spec/unit/portugal_with_a_without_paf_spec.rb +1 -1
- data/spec/unit/portugal_with_ch_and_il_without_paf_spec.rb +1 -1
- data/spec/unit/portugal_without_paf_spec.rb +1 -1
- data/spec/unit/pseudorandom_multirange_enumerator_spec.rb +1 -1
- data/spec/unit/referendum_polychotomy_spec.rb +1 -1
- data/spec/unit/representatives_polychotomy_spec.rb +1 -1
- data/spec/unit/slovakia_spec.rb +1 -1
- data/spec/unit/slovenia_spec.rb +1 -1
- data/spec/unit/spain_spec.rb +1 -1
- data/spec/unit/sweden_20140914_spec.rb +1 -1
- data/spec/unit/sweden_spec.rb +1 -1
- data/spec/unit/united_kingdom_spec.rb +1 -1
- data/spec/unit/united_kingdom_with_brexit_and_chuk_spec.rb +1 -1
- data/spec/unit/united_kingdom_with_brexit_spec.rb +1 -1
- data/spec/unit/united_kingdom_with_tig_spec.rb +1 -1
- data/spec/unit/wallonia_spec.rb +1 -1
- metadata +23 -4
- data/lib/sapor/regional_data/catalonia-jxcat.rb +0 -109
- data/lib/sapor/regional_data/catalonia-no-jxsi.rb +0 -96
@@ -0,0 +1,61 @@
|
|
1
|
+
#
|
2
|
+
# Statistical Analysis of Polling Results (SAPoR)
|
3
|
+
# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
4
|
+
#
|
5
|
+
# This file is part of SAPoR.
|
6
|
+
#
|
7
|
+
# SAPoR is free software: you can redistribute it and/or modify it under the
|
8
|
+
# terms of the GNU General Public License as published by the Free Software
|
9
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
10
|
+
# version.
|
11
|
+
#
|
12
|
+
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
13
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
14
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
17
|
+
#
|
18
|
+
|
19
|
+
SOURCE = '2020-01-01_partifordeling_1_st_2017.csv'.freeze
|
20
|
+
TARGET = '../../lib/sapor/regional_data/norway-20170911.psv'.freeze
|
21
|
+
|
22
|
+
parties = []
|
23
|
+
total_votes = 0
|
24
|
+
File.open(TARGET, 'w') do |output|
|
25
|
+
output.puts '# Statistical Analysis of Polling Results (SAPoR)'
|
26
|
+
output.puts '# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>'
|
27
|
+
output.puts '#'
|
28
|
+
output.puts '# This file is part of SAPoR.'
|
29
|
+
output.puts '#'
|
30
|
+
output.puts '# SAPoR is free software: you can redistribute it and/or' \
|
31
|
+
' modify it under the'
|
32
|
+
output.puts '# terms of the GNU General Public License as published by the' \
|
33
|
+
' Free Software'
|
34
|
+
output.puts '# Foundation, either version 3 of the License, or (at your' \
|
35
|
+
' option) any later'
|
36
|
+
output.puts '# version.'
|
37
|
+
output.puts '#'
|
38
|
+
output.puts '# SAPoR is distributed in the hope that it will be useful, but' \
|
39
|
+
' WITHOUT ANY'
|
40
|
+
output.puts '# WARRANTY; without even the implied warranty of' \
|
41
|
+
' MERCHANTABILITY or FITNESS FOR'
|
42
|
+
output.puts '# A PARTICULAR PURPOSE. See the GNU General Public License' \
|
43
|
+
' for more details.'
|
44
|
+
output.puts '#'
|
45
|
+
output.puts '# You can find a copy of the GNU General Public License in' \
|
46
|
+
' /doc/gpl.txt'
|
47
|
+
output.puts '#'
|
48
|
+
File.open(SOURCE).each do |line|
|
49
|
+
next if line.start_with?('Fylkenummer')
|
50
|
+
elements = line.chomp.split(';')
|
51
|
+
constituency = elements[1]
|
52
|
+
party = elements[7]
|
53
|
+
next if party == 'Blanke'
|
54
|
+
parties << party unless parties.include?(party)
|
55
|
+
votes = elements[12].to_i
|
56
|
+
total_votes += votes
|
57
|
+
output.puts "#{constituency} | #{party} | #{votes}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
puts 'Parties: ' + parties.sort.join(', ')
|
61
|
+
puts "Total votes: #{total_votes}"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C)
|
4
|
+
# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
5
|
#
|
6
6
|
# This file is part of SAPoR.
|
7
7
|
#
|
@@ -39,7 +39,7 @@ PARTIES = ['Prawo i Sprawiedliwość',
|
|
39
39
|
|
40
40
|
File.open(TARGET, 'w') do |output|
|
41
41
|
output.puts '# Statistical Analysis of Polling Results (SAPoR)'
|
42
|
-
output.puts '# Copyright (C)
|
42
|
+
output.puts '# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>'
|
43
43
|
output.puts '#'
|
44
44
|
output.puts '# This file is part of SAPoR.'
|
45
45
|
output.puts '#'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C)
|
4
|
+
# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
5
|
#
|
6
6
|
# This file is part of SAPoR.
|
7
7
|
#
|
@@ -44,7 +44,7 @@ PARTIES = ['Prawo i Sprawiedliwość',
|
|
44
44
|
|
45
45
|
File.open(TARGET, 'w') do |output|
|
46
46
|
output.puts '# Statistical Analysis of Polling Results (SAPoR)'
|
47
|
-
output.puts '# Copyright (C)
|
47
|
+
output.puts '# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>'
|
48
48
|
output.puts '#'
|
49
49
|
output.puts '# This file is part of SAPoR.'
|
50
50
|
output.puts '#'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C)
|
4
|
+
# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
5
|
#
|
6
6
|
# This file is part of SAPoR.
|
7
7
|
#
|
@@ -46,7 +46,7 @@ PARTIES = ['Zjednoczona Prawica',
|
|
46
46
|
|
47
47
|
File.open(TARGET, 'w') do |output|
|
48
48
|
output.puts '# Statistical Analysis of Polling Results (SAPoR)'
|
49
|
-
output.puts '# Copyright (C)
|
49
|
+
output.puts '# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>'
|
50
50
|
output.puts '#'
|
51
51
|
output.puts '# This file is part of SAPoR.'
|
52
52
|
output.puts '#'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C)
|
4
|
+
# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
5
|
#
|
6
6
|
# This file is part of SAPoR.
|
7
7
|
#
|
@@ -43,7 +43,7 @@ PARTIES = ['Prawo i Sprawiedliwość',
|
|
43
43
|
|
44
44
|
File.open(TARGET, 'w') do |output|
|
45
45
|
output.puts '# Statistical Analysis of Polling Results (SAPoR)'
|
46
|
-
output.puts '# Copyright (C)
|
46
|
+
output.puts '# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>'
|
47
47
|
output.puts '#'
|
48
48
|
output.puts '# This file is part of SAPoR.'
|
49
49
|
output.puts '#'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C)
|
4
|
+
# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
5
|
#
|
6
6
|
# This file is part of SAPoR.
|
7
7
|
#
|
@@ -40,7 +40,7 @@ PARTIES = ['Prawo i Sprawiedliwość',
|
|
40
40
|
|
41
41
|
File.open(TARGET, 'w') do |output|
|
42
42
|
output.puts '# Statistical Analysis of Polling Results (SAPoR)'
|
43
|
-
output.puts '# Copyright (C)
|
43
|
+
output.puts '# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>'
|
44
44
|
output.puts '#'
|
45
45
|
output.puts '# This file is part of SAPoR.'
|
46
46
|
output.puts '#'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C)
|
4
|
+
# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
5
|
#
|
6
6
|
# This file is part of SAPoR.
|
7
7
|
#
|
@@ -40,7 +40,7 @@ PARTIES = ['Prawo i Sprawiedliwość',
|
|
40
40
|
|
41
41
|
File.open(TARGET, 'w') do |output|
|
42
42
|
output.puts '# Statistical Analysis of Polling Results (SAPoR)'
|
43
|
-
output.puts '# Copyright (C)
|
43
|
+
output.puts '# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>'
|
44
44
|
output.puts '#'
|
45
45
|
output.puts '# This file is part of SAPoR.'
|
46
46
|
output.puts '#'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C)
|
4
|
+
# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
5
|
#
|
6
6
|
# This file is part of SAPoR.
|
7
7
|
#
|
@@ -22,7 +22,7 @@ TARGET = '../lib/sapor/regional_data/united_kingdom-2015.psv'.freeze
|
|
22
22
|
|
23
23
|
File.open(TARGET, 'w') do |output|
|
24
24
|
output.puts '# Statistical Analysis of Polling Results (SAPoR)'
|
25
|
-
output.puts '# Copyright (C)
|
25
|
+
output.puts '# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>'
|
26
26
|
output.puts '#'
|
27
27
|
output.puts '# This file is part of SAPoR.'
|
28
28
|
output.puts '#'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C)
|
4
|
+
# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
5
|
#
|
6
6
|
# This file is part of SAPoR.
|
7
7
|
#
|
@@ -22,7 +22,7 @@ TARGET = '../../lib/sapor/regional_data/united_kingdom-20170608.psv'.freeze
|
|
22
22
|
|
23
23
|
File.open(TARGET, 'w') do |output|
|
24
24
|
output.puts '# Statistical Analysis of Polling Results (SAPoR)'
|
25
|
-
output.puts '# Copyright (C)
|
25
|
+
output.puts '# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>'
|
26
26
|
output.puts '#'
|
27
27
|
output.puts '# This file is part of SAPoR.'
|
28
28
|
output.puts '#'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C)
|
4
|
+
# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
5
|
#
|
6
6
|
# This file is part of SAPoR.
|
7
7
|
#
|
@@ -22,7 +22,7 @@ TARGET = '../../lib/sapor/regional_data/united_kingdom-20170608-brexit-chuk.psv'
|
|
22
22
|
|
23
23
|
File.open(TARGET, 'w') do |output|
|
24
24
|
output.puts '# Statistical Analysis of Polling Results (SAPoR)'
|
25
|
-
output.puts '# Copyright (C)
|
25
|
+
output.puts '# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>'
|
26
26
|
output.puts '#'
|
27
27
|
output.puts '# This file is part of SAPoR.'
|
28
28
|
output.puts '#'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
3
|
# Statistical Analysis of Polling Results (SAPoR)
|
4
|
-
# Copyright (C)
|
4
|
+
# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
5
5
|
#
|
6
6
|
# This file is part of SAPoR.
|
7
7
|
#
|
@@ -22,7 +22,7 @@ TARGET = '../../lib/sapor/regional_data/united_kingdom-20170608-tig.psv'.freeze
|
|
22
22
|
|
23
23
|
File.open(TARGET, 'w') do |output|
|
24
24
|
output.puts '# Statistical Analysis of Polling Results (SAPoR)'
|
25
|
-
output.puts '# Copyright (C)
|
25
|
+
output.puts '# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>'
|
26
26
|
output.puts '#'
|
27
27
|
output.puts '# This file is part of SAPoR.'
|
28
28
|
output.puts '#'
|
data/lib/sapor.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Statistical Analysis of Polling Results (SAPoR)
|
3
|
-
# Copyright (C)
|
3
|
+
# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
4
4
|
#
|
5
5
|
# This file is part of SAPoR.
|
6
6
|
#
|
@@ -42,6 +42,7 @@ require 'sapor/polychotomy'
|
|
42
42
|
require 'sapor/referendum_polychotomy'
|
43
43
|
require 'sapor/representatives_polychotomy'
|
44
44
|
require 'sapor/first_past_the_post'
|
45
|
+
require 'sapor/many_past_the_post'
|
45
46
|
require 'sapor/largest_remainder'
|
46
47
|
require 'sapor/denominators'
|
47
48
|
require 'sapor/single_district_proportional'
|
@@ -55,8 +56,6 @@ require 'sapor/regional_data/belgium_brussels'
|
|
55
56
|
require 'sapor/regional_data/belgium_flanders'
|
56
57
|
require 'sapor/regional_data/belgium_wallonia'
|
57
58
|
require 'sapor/regional_data/catalonia'
|
58
|
-
require 'sapor/regional_data/catalonia-no-jxsi'
|
59
|
-
require 'sapor/regional_data/catalonia-jxcat'
|
60
59
|
require 'sapor/regional_data/denmark'
|
61
60
|
require 'sapor/regional_data/denmark_with_e'
|
62
61
|
require 'sapor/regional_data/denmark_with_e_and_p'
|
@@ -115,6 +114,7 @@ require 'sapor/regional_data/france'
|
|
115
114
|
require 'sapor/regional_data/greece'
|
116
115
|
require 'sapor/regional_data/hungary'
|
117
116
|
require 'sapor/regional_data/iceland'
|
117
|
+
require 'sapor/regional_data/ireland'
|
118
118
|
require 'sapor/regional_data/latvia'
|
119
119
|
require 'sapor/regional_data/luxembourg'
|
120
120
|
require 'sapor/regional_data/netherlands'
|
data/lib/sapor/denominators.rb
CHANGED
data/lib/sapor/dichotomies.rb
CHANGED
data/lib/sapor/dichotomy.rb
CHANGED
data/lib/sapor/log4r_logger.rb
CHANGED
data/lib/sapor/log_facade.rb
CHANGED
@@ -0,0 +1,113 @@
|
|
1
|
+
#
|
2
|
+
# Statistical Analysis of Polling Results (SAPoR)
|
3
|
+
# Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
|
4
|
+
#
|
5
|
+
# This file is part of SAPoR.
|
6
|
+
#
|
7
|
+
# SAPoR is free software: you can redistribute it and/or modify it under the
|
8
|
+
# terms of the GNU General Public License as published by the Free Software
|
9
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
10
|
+
# version.
|
11
|
+
#
|
12
|
+
# SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
|
13
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
14
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You can find a copy of the GNU General Public License in /doc/gpl.txt
|
17
|
+
#
|
18
|
+
|
19
|
+
module Sapor
|
20
|
+
#
|
21
|
+
# Class representing an electoral system with more than one
|
22
|
+
# district where parties only have a limited number of candidates in each of
|
23
|
+
# the constituencies.
|
24
|
+
#
|
25
|
+
class ManyPastThePost
|
26
|
+
def initialize(last_election_result, last_detailed_election_result,
|
27
|
+
seat_distribution, caps = {}, weights = {})
|
28
|
+
@last_election_result = last_election_result
|
29
|
+
@last_detailed_election_result = last_detailed_election_result
|
30
|
+
@seat_distribution = seat_distribution
|
31
|
+
@caps = caps
|
32
|
+
@weights = weights
|
33
|
+
end
|
34
|
+
|
35
|
+
def project(simulation)
|
36
|
+
multiplicators = calculate_multiplicators(simulation)
|
37
|
+
result = create_empty_result(simulation)
|
38
|
+
@last_detailed_election_result.each_pair do |name, local_last_result|
|
39
|
+
no_of_seats = @seat_distribution[name]
|
40
|
+
caps = @caps.empty? ? {} : @caps[name]
|
41
|
+
seats = local_seats(no_of_seats, local_last_result, multiplicators,
|
42
|
+
caps, @weights)
|
43
|
+
add_seats_to_result(result, seats)
|
44
|
+
end
|
45
|
+
result
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def add_seats_to_result(result, seats)
|
51
|
+
seats.each do |seat|
|
52
|
+
if result.key?(seat)
|
53
|
+
result[seat] += 1
|
54
|
+
else
|
55
|
+
result[seat] = 1
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def calculate_multiplicators(simulation)
|
61
|
+
simulation_sum = simulation.values.inject(:+)
|
62
|
+
last_election_sum = @last_election_result.values.inject(:+)
|
63
|
+
multiplicators = {}
|
64
|
+
simulation.each_key do |choice|
|
65
|
+
new_fraction = simulation[choice].to_f / simulation_sum
|
66
|
+
last_fraction = @last_election_result[choice].to_f / last_election_sum
|
67
|
+
multiplicators[choice] = new_fraction / last_fraction
|
68
|
+
end
|
69
|
+
multiplicators
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_empty_result(simulation)
|
73
|
+
result = {}
|
74
|
+
simulation.each_key do |choice|
|
75
|
+
result[choice] = 0
|
76
|
+
end
|
77
|
+
result[OTHER] = 0
|
78
|
+
result
|
79
|
+
end
|
80
|
+
|
81
|
+
def local_votes(local_last_result, multiplicators)
|
82
|
+
local_votes = {}
|
83
|
+
local_last_result.each_pair do |choice, votes|
|
84
|
+
local_votes[choice] = if multiplicators.key?(choice)
|
85
|
+
votes * multiplicators[choice]
|
86
|
+
else
|
87
|
+
votes
|
88
|
+
end
|
89
|
+
end
|
90
|
+
local_votes
|
91
|
+
end
|
92
|
+
|
93
|
+
def local_quotients(local_votes, no_of_seats, caps, weights)
|
94
|
+
local_quotients = []
|
95
|
+
local_votes.each_pair do |choice, new_value|
|
96
|
+
actual_no_of_seats = caps.empty? ? no_of_seats : [caps[choice], no_of_seats].min
|
97
|
+
actual_weights = weights[actual_no_of_seats - 1]
|
98
|
+
actual_weights.each do |w|
|
99
|
+
local_quotients << [choice, new_value.to_f * w]
|
100
|
+
end
|
101
|
+
end
|
102
|
+
local_quotients
|
103
|
+
end
|
104
|
+
|
105
|
+
def local_seats(no_of_seats, local_last_result, multiplicators, caps,
|
106
|
+
weights)
|
107
|
+
local_votes = local_votes(local_last_result, multiplicators)
|
108
|
+
local_quotients = local_quotients(local_votes, no_of_seats, caps, weights)
|
109
|
+
sorted_quotients = local_quotients.sort { |a, b| b.last <=> a.last }
|
110
|
+
sorted_quotients.map(&:first).slice(0, no_of_seats)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|