Skip to content

Commit

Permalink
Improved living all in same county code
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Oct 7, 2024
1 parent 4f2ea14 commit c925ba9
Showing 1 changed file with 91 additions and 69 deletions.
160 changes: 91 additions & 69 deletions gedcom
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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 {
Expand All @@ -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()))));
Expand Down

0 comments on commit c925ba9

Please sign in to comment.