Skip to content

Commit

Permalink
#100 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed May 3, 2024
1 parent 36a6d76 commit bee3413
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
18 changes: 15 additions & 3 deletions bibcop.pl
Expand Up @@ -597,7 +597,7 @@ sub fix_author {
next;
}
$author =~ s/ ([A-Z])($| )/ $1.$2/g;
if (index($author, ',') eq -1) {
if (index($author, ',') == -1) {
my @words = split(/\s+/, $author);
my $total = @words+0;
if ($total > 1) {
Expand Down Expand Up @@ -664,9 +664,21 @@ sub fix_capitalization {
if ($word =~ /^[a-z].*/) {
$word =~ s/^([a-z])/\U$1/g;
}
if (index($word, '-') != -1) {
$word =~ s/-([a-z])/-\U$1/g;
my @parts = split(/-/, $word, -1);
my $p = 0;
foreach my $part (@parts) {
$p += 1;
if (exists $minors{$part}) {
if ($p > 1) {
my $pre = $parts[$p - 2];
if (not $pre eq '') {
next;
}
}
}
$part =~ s/^([a-z])/\U$1/g;
}
$word = join('-', @parts);
}
return join(' ', @words);
}
Expand Down
7 changes: 7 additions & 0 deletions perl-tests/fixing.pl
Expand Up @@ -43,7 +43,14 @@ package bibcop;
fixes('title', 'TeX: a Great Tool', 'TeX: A Great Tool');
fixes('title', 'TeX: A Great Tool', 'TeX: A Great Tool');
fixes('title', 'Does It Work? an empirical study', 'Does It Work? An Empirical Study');
fixes('title', 'it works? of course!', 'It Works? Of Course!');
fixes('title', 'first; second!', 'First; Second!');
fixes('title', 'Face-to-Face discussion', 'Face-to-Face Discussion');
fixes('title', 'long question---short answer', 'Long Question---Short Answer');
fixes('title', 'long question --- short answer', 'Long Question --- Short Answer');
fixes('title', 'does it work?---of course!', 'Does It Work?---Of Course!');
fixes('title', 'GitHub Audience?---a Thematic Analysis', 'GitHub Audience?---A Thematic Analysis');
fixes('title', 'our in-house rules', 'Our In-House Rules');

fixes('booktitle', 'Proceedings Of IEEE Symposium On Art', 'Proceedings of Symposium on Art');
fixes('booktitle', 'Symposium on Computers', 'Proceedings of the Symposium on Computers');
Expand Down

0 comments on commit bee3413

Please sign in to comment.