From c925ba930c5ddf5a0e7a7edbb7c73ba4f10ed38a Mon Sep 17 00:00:00 2001 From: Nigel Horne Date: Mon, 7 Oct 2024 09:54:45 -0400 Subject: [PATCH] Improved living all in same county code --- gedcom | 160 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 91 insertions(+), 69 deletions(-) diff --git a/gedcom b/gedcom index 1286fc0..f1d3ae0 100755 --- a/gedcom +++ b/gedcom @@ -5843,75 +5843,6 @@ sub print_person } } - # See if this person was born, lived and died all in the same county - if((scalar(@residencelist) > 3) && $birth_country && $death_country && ($birth_country eq $death_country)) { - # TODO: finish this code - my $all_in_one_county = 1; - my $birth_county; - if($placeofbirth =~ /.+,\s*(.+),\s*.+$/) { - $birth_county = $1; - } elsif($placeofbirth =~ /^(.+),\s*.+$/) { - $birth_county = $1; - } - foreach my $residence(@residencelist) { - my $place = $residence->place(); - if(($place !~ /,\s*\Q$birth_country\E$/i)) { - if($birth_country eq 'United Kingdom') { - if(($place !~ /(.+),\s*(UK|England|Wales|Scotland)$/i)) { - $all_in_one_county = 0; - last; - } - } else { - $all_in_one_county = 0; - last; - } - } - if($place =~ /.+,\s*(.+),\s*.+$/) { - if($1 ne $birth_county) { - $all_in_one_county = 0; - last; - } - } elsif($place =~ /^(.+),\s*.+$/) { - if($1 ne $birth_county) { - $all_in_one_county = 0; - last; - } - } - } - foreach my $event(@events) { - if(my $type = $event->type()) { - if(($type eq 'Military service') || ($type eq 'Military')) { - $all_in_one_county = 0; # Possibly served abroad - last; - } - } - my $place = $event->place(); - if(($place !~ /,\s*\Q$birth_country\E$/i)) { - if($birth_country eq 'United Kingdom') { - if(($place !~ /(.+),\s*(UK|England|Wales|Scotland)$/i)) { - $all_in_one_county = 0; - last; - } - } else { - $all_in_one_county = 0; - last; - } - } - if($place =~ /.+,\s*(.+),\s*.+$/) { - if($1 ne $birth_county) { - $all_in_one_county = 0; - last; - } - } elsif($place =~ /^(.+),\s*.+$/) { - if($1 ne $birth_county) { - $all_in_one_county = 0; - last; - } - } - } - die if($opts{'w'} && $all_in_one_county); - } - # Print out the residence strings with semi-colons between each residence if(scalar(@residencestringarray)) { push @phrases, $phrase if($phrase->rtrim()->length()); @@ -5928,6 +5859,8 @@ sub print_person } my $first = $residencelist[0]; + my $all_in_county; + my $all_in_country; if((scalar(@residencelist) == 1) && (my $rdate = $first->date())) { $phrase->set(ucfirst(year({ person => $person, date => $rdate, circa => 'About' }))); } else { @@ -5945,6 +5878,95 @@ sub print_person $bio->rtrim()->append("\n\t"); } if(scalar(@residencelist) > 2) { + # See if this person was born, lived and died all in the same county + if((scalar(@residencelist) > 3) && $birth_country && $death_country && ($birth_country eq $death_country)) { + my $all_in_one_county = 1; + $all_in_country = $birth_country; + + if($placeofbirth =~ /.+,\s*(.+),\s*.+$/) { + $all_in_county = $1; + } elsif($placeofbirth =~ /^(.+),\s*.+$/) { + $all_in_county = $1; + } + foreach my $residence(@residencelist) { + my $place = $residence->place(); + if(($place !~ /,\s*\Q$birth_country\E$/i)) { + if($birth_country eq 'United Kingdom') { + if(($place !~ /.+,\s*(UK|England|Wales|Scotland)$/i)) { + $all_in_one_county = 0; + last; + } + $all_in_country = $1; # Use which country in the UK + } else { + $all_in_one_county = 0; + last; + } + } + if($place =~ /.+,\s*(.+),\s*.+$/) { + if($1 ne $all_in_county) { + $all_in_one_county = 0; + last; + } + } elsif($place =~ /^(.+),\s*.+$/) { + if($1 ne $all_in_county) { + $all_in_one_county = 0; + last; + } + } + } + foreach my $event(@events) { + if(my $type = $event->type()) { + if(($type eq 'Military service') || ($type eq 'Military')) { + $all_in_one_county = 0; # Possibly served abroad + last; + } + } + if(my $place = $event->place()) { + if(($place !~ /,\s*\Q$birth_country\E$/i)) { + if($birth_country eq 'United Kingdom') { + if(($place !~ /.+,\s*(UK|England|Wales|Scotland)$/i)) { + $all_in_one_county = 0; + last; + } + $all_in_country = $1; # Use which country in the UK + } else { + $all_in_one_county = 0; + last; + } + } + if($place =~ /.+,\s*(.+),\s*.+$/) { + if($1 ne $all_in_county) { + $all_in_one_county = 0; + last; + } + } elsif($place =~ /^(.+),\s*.+$/) { + if($1 ne $all_in_county) { + $all_in_one_county = 0; + last; + } + } + } + } + if($all_in_one_county) { + if($phrase->length()) { + push @phrases, $phrase; + } + if(scalar(@phrases)) { + $bio->append(conjunction(map { $_->as_string() } @phrases))->append('. '); + @phrases = (); + $phrase = Data::Text->new(); + } + $bio->append("$firstname spent all of " . + (($person->pronoun() eq 'She') ? 'her' : 'his') . + " life in $all_in_county " . + (($ENV{'LANG'} && ($ENV{'LANG'} =~ /^en_US/)) ? ',' : 'in') . + " $all_in_country. "); + } else { + undef $all_in_country; + undef $all_in_county; + } + } + $phrase->set('Throughout ' . lc($person->possessive()) . ' life'); } else { $phrase->set(ucfirst(i18n('during %s life', lc($person->possessive()))));