Skip to content

Commit

Permalink
#53 checking of authors is stronger now
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Sep 3, 2023
1 parent bd0ab03 commit a0c5573
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
25 changes: 18 additions & 7 deletions bibcop.pl
Expand Up @@ -132,21 +132,32 @@ sub check_author {
return;
}
my $author = clean_tex($entry{'author'});
if (index($author, '{') != -1) {
return;
}
my @authors = split(/\s+and\s+/, $author);
my $pos = 0;
for my $a (@authors) {
$pos += 1;
if ($a eq 'others') {
next;
}
if (not $a =~ /^[A-Z][^ .]+( [A-Z][^ .]+)*(,( [A-Z][^ ]+)+)?$/) {
return "The format of @{[as_position($pos)]} 'author' is wrong, use something like 'Knuth, Donald E. and Duane, Bibby'"
if (index($a, ' ') != -1 and index($a, ',') == -1) {
return "The last name should go first, all other names must follow, after a comma in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'";
}
if ($author =~ /.*[A-Z]([ ,]|$).*/) {
return "A shortened name must have a tailing dot in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'"
my $npos = 0;
for my $name (split(/[ ,]+/, $a)) {
$npos += 1;
if (index($name, '{') != -1) {
next;
}
if ($name =~ /^[A-Z]\.$/) {
next;
}
if ($name =~ /^[A-Z][^.]+$/) {
next
}
if ($name =~ /^[A-Z]$/) {
return "A shortened name must have a tailing dot in @{[as_position($pos)]} 'author', as in 'Knuth, Donald E.'";
}
return "In @{[as_position($pos)]} 'author' @{[as_position($npos)]} name looks suspicious ($name), use something like 'Knuth, Donald E. and Duane, Bibby'";
}
}
}
Expand Down
1 change: 1 addition & 0 deletions perl-tests/checks.pl
Expand Up @@ -81,6 +81,7 @@ package bibcop;
check_fails($f, ('author' => 'Knuth, Donald E'));
check_fails($f, ('author' => 'Knuth, Donald E. et al.'));
check_fails($f, ('author' => 'Monsalve Diaz, Jose M'));
check_fails($f, ('author' => 'Gomez, Aidan N and Kaiser, {\L}ukasz'));
check_passes($f, ('author' => 'Knuth'));
check_passes($f, ('author' => 'Knuth and others'));
check_passes($f, ('author' => 'Knuth and Duane'));
Expand Down

0 comments on commit a0c5573

Please sign in to comment.