Changeset 2691


Ignore:
Timestamp:
May 13, 2012, 8:52:49 PM (8 years ago)
Author:
goya
Message:

fix doublons premiers mandats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/batch/depute/parse_depute_new.pl

    r2593 r2691  
    3636}
    3737
     38my %premiers_mandats;
    3839sub add_mandat {
    3940  $start = shift;
     
    4647  $cause =~ s/^É/é/;
    4748  $cause =~ s/(du gouvernement) :.*$/\1/i;
    48   $depute{'premiers_mandats'}{"$start / $end / ".lc($cause)} = 1;
     49  $premiers_mandats{"$start / $end / ".lc($cause)} = 1;
    4950  $depute{'debut_mandat'} = max_date($start,$depute{'debut_mandat'});
    5051  $depute{'fin_mandat'} = max_date($end,$depute{'fin_mandat'}) if ($end !~ /^$/ && max_date($end,"20/06/2007") != "20/06/2007");
     
    113114  } elsif ($line =~ /Mandat du ([\d\/]+)( \(.*\))? au ([\d\/]+)( \((.*)\))?/i) {
    114115    add_mandat($1,$3,$5);
     116  } elsif ($line =~ /(Reprise de l'exercice.*député.*) le[ :]+([\d\/]+)/) {
     117    add_mandat($2, "", $1);
    115118  } elsif ($line =~ /class="article-title/) {
    116119    clean_vars();
     
    255258$depute{'nom_de_famille'} = trim($depute{'nom_de_famille'});
    256259
     260#clean doublons mandats
     261my %tmp_mandats;
     262foreach $m (keys %premiers_mandats) {
     263  $date1 = $m;
     264  $date1 =~ s/ \/ .*$//;
     265  if (!$tmp_mandats{$date1} || $tmp_mandats{$date1} =~ / \/ +\/ /) {
     266    $tmp_mandats{$date1} = $m;
     267  }
     268}
     269foreach $m (values %tmp_mandats) {
     270  $depute{'premiers_mandats'}{$m} = 1;
     271}
     272
    257273if ($yml) {
    258274    print "  depute_".$depute{'id_an'}.":\n";
Note: See TracChangeset for help on using the changeset viewer.