Skip to content

Commit

Permalink
More work on improving detection of living with or close to relatives
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Aug 5, 2024
1 parent 1cb8905 commit 77b1154
Showing 1 changed file with 37 additions and 28 deletions.
65 changes: 37 additions & 28 deletions ged2site
Original file line number Diff line number Diff line change
Expand Up @@ -5176,6 +5176,8 @@ sub print_person
'record' => $residence,
'person' => $person,
'date' => $strftime,
'latitude' => $location->lat(),
'longitude' => $location->long(),
'location' => $location
};
}
Expand Down Expand Up @@ -5498,7 +5500,7 @@ sub print_person
next if(!defined($sdate));
next if($sdate ne $rdate);
if(($place =~ /^\s\d/) && (place({ person => $sibling, record => $sr, nopreposition => 1 }) eq $place)) {
push @{$living_with{'siblings'}}, $sibling;
push @{$living_with{'sibling'}}, $sibling;
last;
}
}
Expand Down Expand Up @@ -5758,6 +5760,8 @@ sub print_person
my @sorted_locations = sort { $a->{'location'}->latitude() <=> $b->{'location'}->latitude() } @{$all_locations{$year}};

# $Data::Dumper::Maxdepth = 2;
# print Data::Dumper->new([\@sorted_locations])->Dump();

my $iterator = Array::Iterator->new({ __array__ => \@sorted_locations });
while(my $l = $iterator->get_next()) {
# print Data::Dumper->new([$l])->Dump();
Expand All @@ -5780,7 +5784,10 @@ sub print_person
# print "\t", $distance->yards(), '/', $distance->miles(), "\n";

if(($p1 eq $p2) || places_are_the_same({ person => $person, first => $l->{'record'}, second => $residence, exact => 1 })) {
$close_relative = 1;
# mother and father are single entries, the others are arrays
if($relationship && ((!$living_with{$relationship}) || (($relationship ne 'mother') && ($relationship ne 'father')))) {
push @{$living_with{$relationship}}, $l->{'person'};
}
} elsif(($l->{'location'}->latitude() == $latitude) && ($l->{'location'}->longitude() == $longitude)) {
complain({
person => $person,
Expand Down Expand Up @@ -5854,8 +5861,8 @@ sub print_person
if(scalar(@people_near_p2)) {
while(my $p = pop(@people_near_p2)) {
if(my $r = $person->relationship($p->{'person'})) {
push @people_living_together, "$r " .
$p->{'person'}->as_string();
push @people_living_together,
"$r " . $p->{'person'}->as_string();
}
}
}
Expand Down Expand Up @@ -5922,10 +5929,10 @@ sub print_person
$residence->address() &&
places_are_the_same({ person => $child, first => $residence, second => $event, exact => 1 })) {
if($child->sex() eq 'F') {
push @{$living_with{'daughters'}}, $child;
push @{$living_with{'daughter'}}, $child;
$spdeath_dt = undef;
} else {
push @{$living_with{'sons'}}, $child;
push @{$living_with{'son'}}, $child;
$spdeath_dt = undef;
}
last CHILD;
Expand Down Expand Up @@ -5956,10 +5963,10 @@ sub print_person
$residencestring =~ s/(.+), (his|her) /$1 and $2 /;
}
if(scalar(keys %living_with)) {
if($opts{'w'}) {
$Data::Dumper::Maxdepth = 2;
print STDERR __LINE__, ": TODO ($rdate): ", Data::Dumper->new([\%living_with])->Dump();
}
# if($opts{'w'}) {
# $Data::Dumper::Maxdepth = 2;
# print STDERR __LINE__, ": TODO ($rdate): ", Data::Dumper->new([\%living_with])->Dump();
# }

delete $living_with{'mother'};
delete $living_with{'father'};
Expand All @@ -5970,36 +5977,34 @@ sub print_person
' was living with ' .
lcfirst($person->possessive());

if($living_with{'daughters'}) {
# TODO: more than one daughter
my @daughters = @{$living_with{'daughters'}};
if($living_with{'daughter'}) {
my @daughters = @{$living_with{'daughter'}};
$residencestring .= i18n((scalar(@daughters) > 1) ? ' daughters, ' : ' daughter ') .
conjunction(map { given_names($_) } @daughters) . ',' .
i18n(' following the death of ') .
(($sex eq 'M') ? 'his wife ' : 'her husband ') .
year(date => dateofdeath($spouses[0]));
delete $living_with{'daughters'};
delete $living_with{'daughter'};
}
if($living_with{'sons'}) {
# TODO: more than one son
my @sons = @{$living_with{'sons'}};
if($living_with{'son'}) {
my @sons = @{$living_with{'son'}};
$residencestring .= i18n((scalar(@sons) > 1) ? ' sons, ' : ' son ') .
conjunction(map { given_names($_) } @sons) . ',' .
i18n(' following the death of ') .
(($sex eq 'M') ? 'his wife ' : 'her husband ') .
year(date => dateofdeath($spouses[0]));
delete $living_with{'sons'};
delete $living_with{'son'};
}
if(my $in_law = $living_with{'brother-in-law'}) {
# TODO: brothers-in-law
$residencestring .= i18n(' brother-in-law, ') .
$in_law->as_string();
delete $living_with{'brother-in-law'};
}
if($living_with{'siblings'}) {
if($living_with{'sibling'}) {
# Print out all the siblings this person was living with
# as an adult
my @siblings = @{$living_with{'siblings'}};
my @siblings = @{$living_with{'sibling'}};
my $sex = $siblings[0]->sex();
if(scalar(@siblings) == 1) {
$residencestring .= i18n(($sex eq 'F') ? ' sister, ' : ' brother, ') .
Expand Down Expand Up @@ -6035,7 +6040,11 @@ sub print_person
die 'TODO: ', $person->as_string(include_years => 1), ' living with ', scalar(@siblings), ' siblings of differing genders';
}
}
delete $living_with{'siblings'};
delete $living_with{'sibling'};
}
if($opts{'w'} && scalar(keys %living_with)) {
$Data::Dumper::Maxdepth = 2;
die $person->as_string({ include_years => 1 }), ": TODO ($rdate): ", Data::Dumper->new([\%living_with])->Dump();
}
}
$living_alone = 0;
Expand All @@ -6052,9 +6061,7 @@ sub print_person
if(scalar(@residencestringarray)) {
$bio .= '.' unless($end_of_sentence || $start_of_paragraph);

if($phrase->length()) {
push @phrases, $phrase;
}
push @phrases, $phrase if($phrase->rtrim()->length());
if(scalar(@phrases)) {
my $text = conjunction(map { $_->as_string() } @phrases);
if(!defined($text)) {
Expand Down Expand Up @@ -6403,7 +6410,7 @@ sub print_person
} else {
$bio .= '. ';
}
$bio .= " $pronoun";
$bio .= $pronoun;

if($ENV{'LANG'} =~ /^en_US/) {
$bio .= ' traveled';
Expand Down Expand Up @@ -6722,11 +6729,11 @@ sub print_person
$bio .= journey({ person => $person, arrival => $event, departure => $previous });
if($phrase->length()) {
push @phrases, $phrase;
$bio_dt->append(conjunction(map { $_->as_string() } @phrases))->append('. ');
$bio_dt->append(conjunction(map { $_->as_string() } @phrases))->append('.');
$phrase = Data::Text->new();
@phrases = ();
}
$phrase->set(journey({ person => $person, arrival => $event, departure => $previous }));
$phrase->set(' ' . journey({ person => $person, arrival => $event, departure => $previous }));
} else {
# Two arrival records, put into one sentence for improved readability
my $date1 = year({ record => $previous });
Expand Down Expand Up @@ -9293,7 +9300,9 @@ sub print_person
'record' => $birth,
'person' => $person,
'date' => $dateofbirth,
'location' => $location
'location' => $location,
'latitude' => $location->lat(),
'longitude' => $location->long()
}
};
} else {
Expand Down

0 comments on commit 77b1154

Please sign in to comment.