| 1 | package Genealogy::Obituary::Parser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use DateTime::Format::Text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use JSON::MaybeXS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use Params::Get 0.13; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use Return::Set 0.03; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use Params::Validate::Strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 5 | our @EXPORT_OK = qw(parse_obituary); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | our $geocoder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # TODO: use Lingua::EN::Tagger; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # TODO: add more general code, e.g. where it looks for father, also look for mother | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # TODO: parse https://funeral-notices.co.uk/notice/adams/5244000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | Genealogy::Obituary::Parser - Extract structured family relationships from obituary text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | Version 0.04 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | our $VERSION = '0.04'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | use Genealogy::Obituary::Parser qw(parse_obituary); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | my $text = 'She is survived by her husband Paul, daughters Anna and Lucy, and grandchildren Jake and Emma.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | my $data = parse_obituary($text); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # $data = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # spouse => ['Paul'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # children => ['Anna', 'Lucy'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # grandchildren => ['Jake', 'Emma'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | This module parses freeform obituary text and extracts structured family relationship data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | for use in genealogical applications. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | It parses obituary text and extract structured family relationship data, including details about children, parents, spouse, siblings, grandchildren, and other relatives. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | =head2 parse_obituary($text) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | The routine processes the obituary content to identify and organize relevant family information into a clear, structured hash. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | It returns a hash reference containing structured family information, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | with each family member's data organized into distinct categories such as children, spouse, parents, siblings, etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | Takes a string, or a ref to a string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | =head3 API SPECIFICATION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | =head4 INPUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 'text' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 'type' => 'string', # or stringref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 'min' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 'max' => 10000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | }, 'geocoder' => { # used to geocode locations to verify they exist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 'type' => 'object', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 'can' => 'geocode', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 'optional' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | =head4 OUTPUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | =item * No matches: undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | type => 'hashref', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 'min' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 'max' => 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | sub parse_obituary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 74 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_obituary: called CC=138 SCAR=60.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 74 | my $params = Params::Validate::Strict::validate_strict({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | args => Params::Get::get_params('text', \@_), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | schema => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 'text' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 'type' => 'string', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 'min' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 'max' => 10000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | }, 'geocoder' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 'type' => 'object', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 'can' => 'geocode', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 'optional' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 69 | my $text = $params->{'text'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 69 | ▶ | if(my $geo = $params->{'geocoder'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $geocoder = $geo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 69 | ▶ | Carp::croak(__PACKAGE__, ': Usage: parse_obituary($text)') unless defined($text); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 69 | ▶ | if(ref($text) eq 'SCALAR') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $text = ${$text}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # Quick scan to get started | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub parse_obituary_quick { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_obituary_quick: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my %data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my @patterns = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | [ qr/\bdaughters?\s+([^.,;]+)/i, 'children' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | [ qr/\bsons?\s+([^.,;]+)/i, 'children' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | [ qr/\bchildren\s+([^.,;]+)/i, 'children' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | [ qr/\bgrandchildren\s+([^.;]+)/i, 'grandchildren' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | [ qr/\bwife\s+([^.,;]+)/i, 'spouse' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | [ qr/\bhusband\s+([^.,;]+)/i, 'spouse' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | [ qr/\bhis parents were\s+([^.,;]+)/i,'parents' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | [ qr/\bhis father was\s+([^.,;]+)/i, 'parents' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | [ qr/\bhis mother was\s+([^.,;]+)/i, 'parents' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | [ qr/\bsister(?:s)?\s+([^.,;]+)/i, 'siblings' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | [ qr/\bbrother(?:s)?\s+([^.,;]+)/i, 'siblings' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | [ qr/\bsiblings\s+([^.,;]+)/i, 'siblings' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | for my $p (@patterns) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my ($re, $field) = @$p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | while ($text =~ /$re/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $list = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | next unless $list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # Robust splitting on commas and "and" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my @names = grep { length } map { s/^\s+|\s+$//gr } split /\s*(?:,|(?:\band\b))\s*/i, $list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | push @{$data{$field}}, map { { 'name' => $_ } } @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | return \%data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # my %family = %{parse_obituary_quick($text)}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 69 | my %family; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # Helper to extract people from a specific section and remove empty entries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 6 | ▶ | sub extract_people_section { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_people_section: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 6 | my $section = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 6 | ▶ | return unless $section; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 6 | $section =~ s/\s+and\s+/, /g; # Ensure "and" is treated as a separator | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 6 | $section =~ s/([A-Za-z]+),\s+([A-Z]{2})/$1<<COMMA>>$2/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 6 | my @entries = split /\s*,\s*/, $section; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 6 | my @people; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 6 | foreach my $entry (@entries) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 16 | $entry =~ s/<<COMMA>>/, /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 16 | my ($name, $spouse, $location) = ('', '', ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # Match "Ian (Terry) Girvan of Surrey, BC" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 16 | ▶ | if ($entry =~ /^(\w+)\s+\(([^)]+)\)\s+(\w+)\s+of\s+(.+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | $name = "$1 $3"; $spouse = $2; $location = $4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # Match "Gwen Steeves (Leslie) of Riverview, NB" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | elsif ($entry =~ /^(.+?)\s+\(([^)]+)\)\s+of\s+(.+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | $name = $1; $spouse = $2; $location = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # Match "Carol Girvan of Dartmouth, NS" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | elsif ($entry =~ /^(.+?)\s+of\s+(.+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | $name = $1; $location = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # Match names only (e.g. for siblings) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 13 | $name = $entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 16 | ▶ | next if !$name; # Skip if name is empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 14 | ▶ | next if($name =~ /^father-in-law\sto\s/); # Skip follow ons | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 13 | ▶ | last if($name =~ /^devoted\s/i); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 12 | ▶ | last if($name =~ /^loved\s/i); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # Create a hash and filter out blank fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 12 | my %person = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | spouse => $spouse, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | location => $location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # Remove blank fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 12 | ▶ | %person = map { $_ => $person{$_} } grep { defined $person{$_} && $person{$_} ne '' } keys %person; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $person{$_} && $person{$_} ne ''
MC/DC50%1/2
defined $person{$_} && $person{$_} ne ''
defined $person{$_}
$person{$_} ne ''
Truth table66%2/3
A && B
A= defined $person{$_}B= $person{$_} ne ''
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 12 | push @people, \%person; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 6 | return \@people; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | ▶ | sub extract_names_from_phrase { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_names_from_phrase: called CC=4 SCAR=18.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | my $phrase = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | my @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | $phrase =~ s/[.;]//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # Case: "Christopher, Thomas, and Marsha Cloud" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | ▶ | if ($phrase =~ /^((?:\w+\s*,\s*)+\w+),?\s*and\s+(\w+)\s+(\w+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my ($pre, $last_first, $last) = ($1, $2, $3); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my @firsts = split(/\s*,\s*/, $pre); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | push @firsts, $last_first; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | push @names, map { "$_ $last" } @firsts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # Case: "Christopher and Thomas Cloud" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | ▶ | if ($phrase =~ /^([\w\s]+?)\s+and\s+(\w+)\s+(\w+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my ($first_part, $second_first, $last) = ($1, $2, $3); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my @firsts = split(/\s*,\s*|\s+and\s+/, $first_part); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | push @names, map { "$_ $last" } (@firsts, $second_first); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | return @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # Fallback: Split by comma or 'and' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | $phrase =~ s/, and grandchildren.+//; # Handle "Anna and Lucy, and grandchildren Jake and Emma" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | my @parts = split /\s*(?:,|and)\s*/, $phrase; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | ▶ | push @names, grep { defined($_) && $_ ne '' } @parts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $_ && $_ ne ''
MC/DC0%0/2
defined $_ && $_ ne ''
defined $_
$_ ne ''
Truth table33%1/3
A && B
A= defined $_B= $_ ne ''
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | return @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # Correct extraction of children (skipping "his/her") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 69 | ▶ | if ($text =~ /survived by (his|her) children\s*([^\.;]+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | my $children_text = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | $family{children} = extract_people_section($children_text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } elsif ($text =~ /Loving mum to\s*([^\.;]+)/i) { # Look for the phrase "Loving mum to" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | my $children_text = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | $family{children} = extract_people_section($children_text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } elsif ($text =~ /Loving father of\s*([^\.;]+)/i) { # Look for the phrase "Loving father of" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | my $children_text = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 1 | $family{children} = extract_people_section($children_text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } elsif($text =~ /mother of\s*([^\.;]+)?,/i) { # Look for the phrase "mother of" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | my $children_text = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | $children_text =~ s/, grandmother.+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | $family{children} = extract_people_section($children_text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } elsif($text =~ /sons,?\s*([a-z]+)\s+and\s+([a-z]+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 3 | my @children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | my @grandchildren; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 3 | push @children, { name => $1, sex => 'M' }, { name => $2, sex => 'M' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 3 | ▶ | if($text =~ /\bdaughter,?\s([a-z]+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | push @children, { 'name' => $1, 'sex' => 'F' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 3 | ▶ | if($text =~ /\bgranddaughter,?\s([a-z]+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | push @grandchildren, { 'name' => $1, 'sex' => 'F' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 3 | ▶ | $family{children} = \@children if @children; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 3 | ▶ | $family{grandchildren} = \@grandchildren if @grandchildren; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } elsif($text =~ /Surviving are (?:a )?daughters?,\s*Mrs\.\s+(\w+)\s+\(([^)]+)\)\s+(\w+),\s+([^;]+?);/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # Handle "Surviving are a daughter, Mrs. Walter (Ruth Ann) Gerke, Fort Wayne" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my @children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my $spouse_first = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my $daughter_name = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my $spouse_last = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $location = $4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $location =~ s/,\s*$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | push @children, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | name => $daughter_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | location => $location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | sex => 'F', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | spouse => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | name => "$spouse_first $spouse_last", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | sex => 'M' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $family{children} = \@children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 62 | my @children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # my $tagger = Lingua::EN::Tagger->new(longest_noun_phrase => 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | # my $tagged = $tagger->add_tags($text); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 62 | ▶ | if($text =~ /\ssons,\s*(.*?);/s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 2 | my $sons_text = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | ▶ | if($sons_text =~ /, all of (.+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | my $location = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | ▶ | while($sons_text =~ /([\w. ]+?),\s/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 3 | my $son = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 3 | ▶ | if($son =~ /(\w+)\s+and\s+(\w+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | push @children, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | name => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | location => $location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | sex => 'M', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | }, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | name => $2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | location => $location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | sex => 'M', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 2 | push @children, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | name => $son, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | location => $location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | sex => 'M', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 1 | ▶ | while($sons_text =~ /([\w. ]+?),\s*([\w. ]+?)(?:\s+and|\z)/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 2 | push @children, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | name => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | location => $2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | sex => 'M', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 62 | ▶ | if($text =~ /\sdaughters?,\s*Mrs\.\s+(.+?)\s+(\w+),\s+([^;]+)\sand/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | push @children, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | name => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | location => $3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | sex => 'F', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | spouse => { 'name' => $2, sex => 'M' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } elsif($text =~ /one daughter,\s*(.+?),\s*(.+?);/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | my $location = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 1 | ▶ | if($name =~ /(\w+)\s+(\w+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 1 | push @children, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | name => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | location => $location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | sex => 'F', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | spouse => { name => $2, sex => 'M' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | push @children, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | name => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | location => $location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | sex => 'F', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 62 | ▶ | $family{children} = \@children if @children; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 62 | ▶ | if(!$family{'children'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 60 | ▶ | while($text =~ /\b(son|daughter)s?,\s*([A-Z][a-z]+(?:\s+\([A-Z][a-z]+\))?)\s*(?:and their children ([^.;]+))?/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 2 | ▶ | my $sex = $1 eq 'son' ? 'M' : 'F'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 2 | my $child = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 2 | my $grandkids = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 2 | ▶ | if(my @grandchildren = $grandkids ? split /\s*,\s*|\s+and\s+/, $grandkids : ()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | push @children, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | name => $child, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | sex => $sex, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | grandchildren => \@grandchildren, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | ▶ | } elsif(($sex eq 'F') && ($child =~ /(.+)\s+\((.+)\)/)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$sex eq "F" and $child =~ /(.+)\s+\((.+)\)/
MC/DC50%1/2
$sex eq "F" and $child =~ /(.+)\s+\((.+)\)/
$sex eq "F"
$child =~ /(.+)\s+\((.+)\)/
Truth table66%2/3
A and B
A= $sex eq "F"B= $child =~ /(.+)\s+\((.+)\)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 1 | push @children, { name => $1, sex => 'F', spouse => { name => $2, sex => 'M' } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } elsif($child ne 'Mrs') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | push @children, { name => $child, sex => $sex } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 62 | ▶ | $family{children} = \@children if @children; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 69 | ▶ | if(!$family{'children'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 59 | ▶ | if($text =~ /\ssons?[,\s]\s*(.+?)[;\.]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $raw = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $raw =~ s/\sand their .+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my @children = extract_names_from_phrase($raw); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | push @{$family{children}}, map { { name => $_, sex => 'M' } } @children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 59 | ▶ | if($text =~ /\sdaughters?[,\s]\s*(.+?)[;\.]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 1 | my $raw = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 1 | $raw =~ s/\sand their .+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 1 | my @children = extract_names_from_phrase($raw); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 1 | push @{$family{children}}, map { { name => $_, sex => 'F' } } @children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # Extract grandchildren | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 69 | ▶ | if(!$family{'grandchildren'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 68 | ▶ | if($text =~ /grandchildren\s+([^\.;]+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 3 | my @grandchildren = split /\s*(?:,|and)\s*/i, $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 3 | ▶ | if(scalar(@grandchildren)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 3 | ▶ | $family{'grandchildren'} = [ map { { 'name' => $_ } } grep { defined $_ && $_ ne '' } @grandchildren ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $_ && $_ ne ''
MC/DC50%1/2
defined $_ && $_ ne ''
defined $_
$_ ne ''
Truth table66%2/3
A && B
A= defined $_B= $_ ne ''
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 69 | ▶ | if($family{'grandchildren'} && scalar @{$family{grandchildren}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$family{"grandchildren"} and scalar @{$family{"grandchildren"};}
MC/DC100%1/1
$family{"grandchildren"} and scalar @{$family{"grandchildren"};}
$family{"grandchildren"}
Truth table100%2/2
A
A= $family{"grandchildren"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 4 | ▶ | while((exists $family{'grandchildren'}->[0]) && (length($family{'grandchildren'}->[0]) == 0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $family{"grandchildren"}[0] and length $family{"grandchildren"}[0] == 0
MC/DC0%0/2
exists $family{"grandchildren"}[0] and length $family{"grandchildren"}[0] == 0
exists $family{"grandchildren"}[0]
length $family{"grandchildren"}[0] == 0
Truth table33%1/3
A and B
A= exists $family{"grandchildren"}[0]B= length $family{"grandchildren"}[0] == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | shift @{$family{'grandchildren'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 4 | ▶ | if($family{'grandchildren'}->[0] =~ /brothers/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if(!exists $family{'brothers'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | shift @{$family{'grandchildren'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $family{'brothers'} = extract_people_section(join(', ', @{$family{'grandchildren'}})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | delete $family{grandchildren}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 65 | delete $family{grandchildren}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 69 | ▶ | if((!defined($family{'grandchildren'})) || (($#{$family{'grandchildren'}}) <= 0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $family{"grandchildren"} or $#{$family{"grandchildren"};} <= 0
MC/DC100%2/2
not defined $family{"grandchildren"} or $#{$family{"grandchildren"};} <= 0
not defined $family{"grandchildren"}
$#{$family{"grandchildren"};} <= 0
Truth table100%3/3
not(A) or B
A= not defined $family{"grandchildren"}B= $#{$family{"grandchildren"};} <= 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # handle devoted Grandma to Tom, Dick, and Harry and loved Mother-in-law to Jack and Jill" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 66 | my ($grandchildren_str) = $text =~ /Grandma to (.*?)(?: and loved|$)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # Normalize and split into individual names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 66 | my @grandchildren; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 66 | ▶ | if($grandchildren_str) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 1 | @grandchildren = split /,\s*|\s+and\s+/, $grandchildren_str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 66 | ▶ | if(scalar(@grandchildren)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 1 | $family{'grandchildren'} = \@grandchildren; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } elsif($text =~ /grandm\w+\s/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 1 | my $t = $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 1 | $t =~ s/.+(grandm\w+\s+.+?\sand\s[\w\.;,]+).+/$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | ▶ | $family{grandchildren} = [ split /\s*(?:,|and)\s*/i, ($t =~ /grandm\w+\sto\s+([^\.;]+)/i)[0] || '' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
($t =~ /grandm\w+\sto\s+([^\.;]+)/i)[0] || ''
MC/DC0%0/1
($t =~ /grandm\w+\sto\s+([^\.;]+)/i)[0] || ''
($t =~ /grandm\w+\sto\s+([^\.;]+)/i)[0]
Truth table50%1/2
A
A= ($t =~ /grandm\w+\sto\s+([^\.;]+)/i)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # Extract siblings (sisters and brothers) correctly, skipping "her" or "his" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 69 | ▶ | if($text =~ /predeceased by (his|her) sisters?\s*([^;\.]+);?/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 2 | my $sisters_text = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 2 | $sisters_text =~ s/^,\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 2 | $family{sisters} = extract_people_section($sisters_text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 67 | ▶ | while($text =~ /\bsister[,\s]\s*([A-Z][a-z]+(?:\s+[A-Z][a-z.]+)*)(?:,\s*([A-Z][a-z]+))?/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 2 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 2 | ▶ | $family{'sisters'} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$family{"sisters"} ||= []
MC/DC0%0/1
$family{"sisters"} ||= []
$family{"sisters"}
Truth table50%1/2
A
A= $family{"sisters"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 2 | ▶ | if($name eq 'Mrs') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | ▶ | if($text =~ / sister,\s*Mrs\.\s+([A-Z][a-zA-Z]+\s+[A-Z][a-zA-Z]+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 1 | $name = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | undef $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 2 | ▶ | if($name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 2 | ▶ | push @{$family{sisters}}, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | sex => 'F', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | status => ($text =~ /\bpredeceased by.*?$name/i) ? 'deceased' : 'living', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 67 | ▶ | if(!exists($family{'sisters'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 65 | ▶ | if($text =~ /\stwo\ssisters,\s*(.*?)\sand\s(.*?)[;:]/s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 1 | my($first, $second) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 1 | foreach my $sister($first, $second) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 2 | ▶ | if($sister =~ /Mrs\.\s(.+?),\s(.+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 2 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 2 | my $location = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 2 | $location =~ s/,$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 2 | ▶ | if($name =~ /(\w+)\s+(\w+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 2 | push @{$family{sisters}}, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | name => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | location => $location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | sex => 'F', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | spouse => { 'name' => $2, 'sex' => 'M' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | push @{$family{sisters}}, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | location => $location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | sex => 'F', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | push @{$family{sisters}}, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | name => $sister, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | sex => 'F', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 67 | ▶ | if($family{'sisters'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | # Deduplicate by serializing hashes for comparison | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 3 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | my @sisters = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 4 | my $key = JSON::MaybeXS->new->canonical(1)->encode($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 4 | !$seen{$key}++ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 3 | } @{$family{sisters}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 3 | $family{sisters} = \@sisters; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 69 | ▶ | if($text =~ /predeceased by (his|her) brothers?\s*([^;\.]+);?/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $brothers_text = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $brothers_text =~ s/^,\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | $family{brothers} = extract_people_section($brothers_text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | # TODO: mark all statuses to deceased | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 69 | ▶ | while ($text =~ /\bbrother,\s*([A-Z][a-z]+(?:\s+[A-Z][a-z.]+)*)(?:,\s*([A-Z][a-z]+))?/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 1 | ▶ | $family{'brothers'} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$family{"brothers"} ||= []
MC/DC0%0/1
$family{"brothers"} ||= []
$family{"brothers"}
Truth table50%1/2
A
A= $family{"brothers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 1 | ▶ | push @{$family{brothers}}, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | name => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | status => ($text =~ /\bpredeceased by.*?$1/i) ? 'deceased' : 'living', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 69 | ▶ | if((!$family{'brothers'}) && (!$family{'sisters'}) && (!$family{'siblings'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$family{"brothers"} or $family{"sisters"} or $family{"siblings"}
$family{"brothers"} or $family{"sisters"}
MC/DC66%2/3
$family{"brothers"} or $family{"sisters"} or $family{"siblings"}
$family{"brothers"}
$family{"sisters"}
$family{"siblings"}
Truth table75%3/4
A or B or C
A= $family{"brothers"}B= $family{"sisters"}C= $family{"siblings"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 64 | ▶ | if($text =~ /sister of ([a-z]+) and ([a-z]+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 1 | push @{$family{'siblings'}}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | { 'name' => $1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | { 'name' => $2 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 69 | ▶ | if(!exists($family{'brothers'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 68 | ▶ | if($text =~ /\sbrothers,\s*(.*?)[;\.]/s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 1 | my $brothers_text = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 1 | ▶ | if($brothers_text =~ /, all of (.+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 1 | my $location = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 1 | ▶ | while($brothers_text =~ /([\w. ]+?),\s/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 2 | my $son = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 2 | ▶ | if($son =~ /(\w+)\s+and\s+(\w+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 1 | push @{$family{brothers}}, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | name => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | location => $location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | sex => 'M', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | }, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | name => $2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | location => $location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | sex => 'M', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 1 | push @{$family{brothers}}, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | name => $son, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | location => $location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | sex => 'M', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | while($brothers_text =~ /([\w. ]+?),\s*([\w. ]+?)(?:\s+and|\z)/g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | push @{$family{brothers}}, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | name => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | location => $2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | sex => 'M', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 69 | ▶ | if(!exists($family{'brothers'}) && $text =~ /\b(?:two|three|four)\s+brothers?,\s*(.+?)(?:,\s*a\s+(?:sister|half-sister)|;)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not exists $family{"brothers"} and $text =~ /\b(?:two|three|four)\s+brothers?,\s*(.+?)(?:,\s*a\s+(?:sister|half-sister)|;)/i
MC/DC0%0/2
not exists $family{"brothers"} and $text =~ /\b(?:two|three|four)\s+brothers?,\s*(.+?)(?:,\s*a\s+(?:sister|half-sister)|;)/i
not exists $family{"brothers"}
$text =~ /\b(?:two|three|four)\s+brothers?,\s*(.+?)(?:,\s*a\s+(?:sister|half-sister)|;)/i
Truth table66%2/3
not(A) and B
A= not exists $family{"brothers"}B= $text =~ /\b(?:two|three|four)\s+brothers?,\s*(.+?)(?:,\s*a\s+(?:sister|half-sister)|;)/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | # Pattern for "two brothers, Name and Name" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my $brothers_text = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my @brothers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # Handle "Charles F. Harris and Berton Harris" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | if($brothers_text =~ /\band\b/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my @names = split /\s+and\s+/, $brothers_text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | foreach my $name (@names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | $name =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | $name =~ s/,\s*$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | push @brothers, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | sex => 'M', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | status => 'living' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | $family{brothers} = \@brothers if(scalar @brothers); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | # Detect nieces/nephews | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 69 | ▶ | $family{nieces_nephews} = ($text =~ /as well as several nieces and nephews/i) ? ['several nieces and nephews'] : []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # Extract parents and clean the names by removing unnecessary details | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 69 | ▶ | if($text =~ /(son|daughter) of the late\s+(.+?)\s+and\s+(.+?)\./i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 2 | my $father = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 2 | my $mother = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | # Remove anything after the first comma in each parent's name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 2 | $father =~ s/,.*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 2 | $mother =~ s/,.*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 2 | ▶ | if($mother =~ /(.+)\s+\((.+)\)\s+(.+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 2 | $mother = "$1 $2"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | $family{parents} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 2 | father => { name => $father }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | mother => { name => $mother }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } elsif($text =~ /parents were (\w+) and (\w+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | $family{parents} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 1 | father => { name => $1 }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | mother => { name => $2 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | # Extract spouse's death year and remove the "(year)" from the name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 69 | ▶ | if($text =~ /(wife|husband) of the late\s+([\w\s]+)\s+\((\d{4})\)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 1 | my $name = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 1 | my $death_year = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 1 | ▶ | $family{'spouse'} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$family{"spouse"} ||= []
MC/DC0%0/1
$family{"spouse"} ||= []
$family{"spouse"}
Truth table50%1/2
A
A= $family{"spouse"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | # Remove the death year part from the spouse's name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 1 | $name =~ s/\s*\(\d{4}\)//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 1 | push @{$family{'spouse'}}, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | death_year => $death_year | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } elsif($text =~ /\bmarried ([^,]+),.*?\b(?:on\s+)?([A-Z][a-z]+ \d{1,2}, \d{4})(?:.*?\b(?:at|in)\s+([^.,]+))?/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 1 | ▶ | $family{'spouse'} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$family{"spouse"} ||= []
MC/DC0%0/1
$family{"spouse"} ||= []
$family{"spouse"}
Truth table50%1/2
A
A= $family{"spouse"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 1 | ▶ | push @{$family{'spouse'}}, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$3 // ""
MC/DC0%0/1
$3 // ""
$3
Truth table50%1/2
A
A= $3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | name => $1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | married => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | date => $2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | place => $3 // '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } elsif($text =~ /husband (?:to|of) the late\s([\w\s]+)[\s\.]/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 1 | ▶ | $family{'spouse'} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$family{"spouse"} ||= []
MC/DC0%0/1
$family{"spouse"} ||= []
$family{"spouse"}
Truth table50%1/2
A
A= $family{"spouse"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 1 | push @{$family{'spouse'}}, { name => $1, status => 'deceased' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } elsif($text =~ /\b(?:wife|husband) of ([^.,;]+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 2 | ▶ | $family{'spouse'} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$family{"spouse"} ||= []
MC/DC0%0/1
$family{"spouse"} ||= []
$family{"spouse"}
Truth table50%1/2
A
A= $family{"spouse"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 2 | push @{$family{'spouse'}}, { name => $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } elsif($text =~ /\bsurvived by her husband ([^.,;]+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 1 | push @{$family{'spouse'}}, { name => $1, 'status' => 'living', 'sex' => 'M' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } elsif($text =~ /\bsurvived by his wife[,\s]+([^.,;]+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 2 | push @{$family{'spouse'}}, { name => $1, 'status' => 'living', 'sex' => 'F' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | # Ensure spouse location is properly handled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 69 | ▶ | if(exists $family{spouse} && (ref $family{'spouse'} eq 'HASH') && defined $family{spouse}[0]{location} && $family{spouse}[0]{location} eq 'the late') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
exists $family{"spouse"} and ref $family{"spouse"} eq "HASH" and defined $family{"spouse"}[0]{"location"} and $family{"spouse"}[0]{"location"} eq "the late"
exists $family{"spouse"} and ref $family{"spouse"} eq "HASH" and defined $family{"spouse"}[0]{"location"}
exists $family{"spouse"} and ref $family{"spouse"} eq "HASH"
MC/DC0%0/4
exists $family{"spouse"} and ref $family{"spouse"} eq "HASH" and defined $family{"spouse"}[0]{"location"} and $family{"spouse"}[0]{"location"} eq "the late"
exists $family{"spouse"}
ref $family{"spouse"} eq "HASH"
defined $family{"spouse"}[0]{"location"}
$family{"spouse"}[0]{"location"} eq "the late"
Truth table40%2/5
A and B and C and D
A= exists $family{"spouse"}B= ref $family{"spouse"} eq "HASH"C= defined $family{"spouse"}[0]{"location"}D= $family{"spouse"}[0]{"location"} eq "the late"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | delete $family{spouse}[0]{location}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | # Extract the funeral information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 69 | ▶ | if($text =~ /funeral service.*?at\s+(.+?),?\s+on\s+(.*?),?\s+at\s+(.+?)\./) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | $family{funeral} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 1 | location => $1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | date => $2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | time => $3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } elsif($text =~ /funeral service.*?at\s+([^\n]+?)\s+on\s+([^\n]+)\s+at\s+([^\n]+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | $family{funeral} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 1 | location => $1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | date => $2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | time => $3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 1 | ▶ | if($family{'funeral'}->{'date'} =~ /(.+?)\.\s{2,}/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 1 | $family{'funeral'}->{'date'} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 1 | ▶ | if($family{'funeral'}->{'date'} =~ /(.+?)\sat\s(.+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # Wednesday 9th March at 1.15pm. Friends etc. etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 1 | $family{'funeral'}->{'date'} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 1 | $family{'funeral'}->{'time'} = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } elsif($text =~ /funeral services.+\sat\s(.+)\sat\s(.+),\swith\s/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | $family{funeral} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 1 | time => $1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | location => $2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } elsif($text =~ /funeral services.+\sat\s(.+),\swith\s/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | $family{funeral} = { location => $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | } elsif($text =~ /services.+\sat\s(.+),\swith\s/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 3 | $family{funeral} = { location => $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | # Extract father-in-law and mother-in-law information (if present) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 69 | ▶ | if($text =~ /father-in-law to\s+([A-Za-z\s]+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 1 | my $father_in_law = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 1 | $family{children_in_law} = [{ name => $father_in_law }]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | } elsif($text =~ /mother-in-law to\s+([A-Za-z\s]+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 1 | my $mother_in_law = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 1 | ▶ | $family{children_in_law} = [ split /\s*(?:,|and)\s*/i, ($text =~ /mother-in-law to\s+([^\.;]+)/i)[0] || '' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
($text =~ /mother-in-law to\s+([^\.;]+)/i)[0] || ''
MC/DC0%0/1
($text =~ /mother-in-law to\s+([^\.;]+)/i)[0] || ''
($text =~ /mother-in-law to\s+([^\.;]+)/i)[0]
Truth table50%1/2
A
A= ($text =~ /mother-in-law to\s+([^\.;]+)/i)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 1 | ▶ | if(scalar($family{children_in_law} == 0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | $family{children_in_law} = [{ name => $mother_in_law }]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | # Extract aunt information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 69 | ▶ | if($text =~ /niece of\s+([A-Za-z]+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 1 | my $aunt = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 1 | $family{aunt} = [{ 'name' => $aunt }]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | # Birth info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 69 | ▶ | if($text =~ /[^\b]Born in ([^,]+),.*?\b(?:on\s+)?([A-Z][a-z]+ \d{1,2}, \d{4})/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | $family{birth} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 1 | place => $1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | date => $2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } elsif($text =~ /[^\b]Born in ([a-z,\.\s]+)\s+on\s+(.+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 1 | $family{'birth'}->{'place'} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 1 | ▶ | if(my $location = _extract_location($1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | $family{'birth'}->{'location'} = $location; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 1 | ▶ | if(my $dt = _extract_date($2)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 1 | $family{'birth'}->{date} = $dt->ymd('/'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 1 | $family{'birth'}->{'place'} =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } elsif($text =~ /S?he was born (.+)\sin ([a-z,\.\s]+)\s+to\s+(.+?)\sand\s(.+?)\./i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 1 | $family{'birth'}->{'place'} = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 1 | my $father = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 1 | my $mother = $4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 1 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 1 | ▶ | if(my $dt = DateTime::Format::Text->parse_datetime($1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 1 | $family{'birth'}->{date} = $dt->ymd('/'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | # TODO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | # if($verbose && $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | # Carp::carp($@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 1 | ▶ | if($mother =~ /(.+)\s+\((.+)\)\s+(.+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 1 | $mother = "$1 $2"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 1 | ▶ | if($father =~ /(.+?)\.\s\s/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | $father = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | $family{parents} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 1 | father => { name => $father }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | mother => { name => $mother } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 1 | ▶ | if($text =~ /survived by (his|her) (father|mother)[\s,;]/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 1 | $family{parents}->{$2}->{'status'} = 'living'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } elsif($text =~ /[^\b]S?he was born\s*(?:on\s+)?([A-Z][a-z]+ \d{1,2}, \d{4})[,\s]+(?:in\s+)([^,]+)?/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 1 | ▶ | if(my $dt = _extract_date($1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 1 | $family{'birth'}->{date} = $dt->ymd('/'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 1 | ▶ | if($2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 1 | $family{'birth'}->{'location'} = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | # Date of death | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 69 | ▶ | if($text =~ /\bpassed away\b.*?\b(?:on\s+)?([A-Z]+ \d{1,2}, \d{4})/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 2 | $family{death}->{date} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 2 | $family{death}->{datetime} = _extract_date($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | # Age at death | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 69 | ▶ | if($text =~ /,\s(\d{1,3}), of\s/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 2 | ▶ | if($1 < 110) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 2 | $family{'death'}->{'age'} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | # Place of death | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 69 | ▶ | if($text =~ /\b(?:passed away|died)\b([a-z0-9\s,]+)\sat\s+(.+?)\./i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 3 | my $place = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 3 | ▶ | if($place =~ /(.+)\s+on\s+([A-Z]+ \d{1,2}, \d{4})/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | $place = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | $family{death}->{date} = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | } elsif($place =~ /(.+)\son\s(.+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 1 | $place = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 1 | ▶ | if(my $dt = _extract_date($2)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 1 | $family{death}->{date} = $dt->ymd('/'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 3 | $place =~ s/^\bthe residence,\s//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 3 | $place =~ s/\bafter a.*$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 3 | $place =~ s/,\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 3 | $family{death}->{place} = $place; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | # Remove blank fields from the main family hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 69 | ▶ | %family = map { $_ => $family{$_} } grep { defined $family{$_} && $family{$_} ne '' } keys %family; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $family{$_} && $family{$_} ne ''
MC/DC0%0/2
defined $family{$_} && $family{$_} ne ''
defined $family{$_}
$family{$_} ne ''
Truth table33%1/3
A && B
A= defined $family{$_}B= $family{$_} ne ''
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | # Remove empty arrays the family hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 69 | foreach my $key (keys %family) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 124 | ▶ | if(ref($family{$key}) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 105 | $family{$key} = [ grep { /\S/ } @{$family{$key}} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 105 | ▶ | if(@{$family{$key}} == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 68 | delete $family{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 69 | ▶ | return if(!scalar keys(%family)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 12 | return Return::Set::set_return(\%family, { type => 'hashref', 'min' => 1, 'max' => 10 }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | sub _extract_date | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_date: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 5 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 5 | my $parser = DateTime::Format::Text->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 5 | my $dt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 5 | eval { $dt = $parser->parse_datetime($text); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 5 | ▶ | return $dt if $dt && !$@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$dt and not $@
MC/DC0%0/2
$dt and not $@
$dt
not $@
Truth table33%1/3
A and not(B)
A= $dtB= not $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 1 | ▶ | sub _extract_location { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_location: called CC=5 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 1 | my $place_text = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 1 | ▶ | unless($geocoder) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 1 | eval { require Geo::Coder::Free }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 1 | ▶ | if($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 1 | Carp::carp(__PACKAGE__, ' (', __LINE__, "): geocoding locations disabled: $@"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | $geocoder = Geo::Coder::Free->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | my @locations = $geocoder->geocode(location => $place_text); # Use array to improve caching | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | return unless scalar(@locations); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | my $result = $locations[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | if(ref($result)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | raw => $place_text, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | # city => $result->{components}{city} || $result->{components}{town}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | # region => $result->{components}{state}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | # country => $result->{components}{country}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | latitude => $result->latitude(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | longitude => $result->longitude() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | raw => $place_text, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | # city => $result->{components}{city} || $result->{components}{town}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | # region => $result->{components}{state}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | # country => $result->{components}{country}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | latitude => $result->{'latitude'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | longitude => $result->{'longitude'} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | Nigel Horne, C<< <njh at nigelhorne.com> >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | Test coverage report: L<https://nigelhorne.github.io/Genealogy-Obituary-Parser/coverage/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | This module is provided as-is without any warranty. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||