Skip to content

Commit 2afc156

Browse files
committed
More consistent handling of parents
1 parent 9ed3b60 commit 2afc156

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

bin/extract

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ sub extract_family_info
152152

153153
# Extract grandchildren
154154
if(!$family{'grandchildren'}) {
155-
my @grandchildren = split /\s*(?:,|and)\s*/i, ($text =~ /grandchildren\s+([^\.;]+)/i)[0];
156-
if(scalar(@grandchildren)) {
157-
$family{'grandchildren'} = [ map { { 'name' => $_ } } grep { defined $_ && $_ ne '' } @grandchildren ];
155+
if($text =~ /grandchildren\s+([^\.;]+)/i) {
156+
my @grandchildren = split /\s*(?:,|and)\s*/i, $1;
157+
if(scalar(@grandchildren)) {
158+
$family{'grandchildren'} = [ map { { 'name' => $_ } } grep { defined $_ && $_ ne '' } @grandchildren ];
159+
}
158160
}
159161
}
160-
if(scalar @{$family{grandchildren}}) {
162+
if($family{'grandchildren'} && scalar @{$family{grandchildren}}) {
161163
while((exists $family{'grandchildren'}->[0]) && (length($family{'grandchildren'}->[0]) == 0)) {
162164
shift @{$family{'grandchildren'}};
163165
}
@@ -248,6 +250,11 @@ sub extract_family_info
248250
father => { name => $father },
249251
mother => { name => $mother },
250252
};
253+
} elsif($text =~ /parents were (\w+) and (\w+)/i) {
254+
$family{parents} = {
255+
father => { name => $1 },
256+
mother => { name => $2 },
257+
};
251258
}
252259

253260
# Extract spouse's death year and remove the "(year)" from the name

gedcom

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13719,12 +13719,14 @@ sub extract_family_info
1371913719

1372013720
# Extract grandchildren
1372113721
if(!$family{'grandchildren'}) {
13722-
my @grandchildren = split /\s*(?:,|and)\s*/i, ($text =~ /grandchildren\s+([^\.;]+)/i)[0];
13723-
if(scalar(@grandchildren)) {
13724-
$family{'grandchildren'} = [ map { { 'name' => $_ } } grep { defined $_ && $_ ne '' } @grandchildren ];
13722+
if($text =~ /grandchildren\s+([^\.;]+)/i) {
13723+
my @grandchildren = split /\s*(?:,|and)\s*/i, $1;
13724+
if(scalar(@grandchildren)) {
13725+
$family{'grandchildren'} = [ map { { 'name' => $_ } } grep { defined $_ && $_ ne '' } @grandchildren ];
13726+
}
1372513727
}
1372613728
}
13727-
if(scalar @{$family{grandchildren}}) {
13729+
if($family{'grandchildren'} && scalar @{$family{grandchildren}}) {
1372813730
while((exists $family{'grandchildren'}->[0]) && (length($family{'grandchildren'}->[0]) == 0)) {
1372913731
shift @{$family{'grandchildren'}};
1373013732
}
@@ -13815,6 +13817,11 @@ sub extract_family_info
1381513817
father => { name => $father },
1381613818
mother => { name => $mother },
1381713819
};
13820+
} elsif($text =~ /parents were (\w+) and (\w+)/i) {
13821+
$family{parents} = {
13822+
father => { name => $1 },
13823+
mother => { name => $2 },
13824+
};
1381813825
}
1381913826

1382013827
# Extract spouse's death year and remove the "(year)" from the name

0 commit comments

Comments
 (0)