diff --git a/bibcop.pl b/bibcop.pl index bbbb3f2..a995711 100755 --- a/bibcop.pl +++ b/bibcop.pl @@ -40,7 +40,7 @@ package bibcop; 'article' => ['doi', 'year', 'title', 'author', 'journal', 'volume', 'number', 'month?', 'publisher?', 'pages?'], 'inproceedings' => ['doi', 'booktitle', 'title', 'author', 'year', 'pages?', 'month?', 'organization?', 'volume?'], 'book' => ['title', 'author', 'year', 'publisher', 'doi?'], - 'misc' => ['title', 'author', 'year', 'eprint?', 'archiveprefix?', 'primaryclass?', 'month?', 'publisher?', 'organization?', 'doi?', 'howpublished?', 'note?'], + 'misc' => ['title', 'author', 'year', 'eprint?', 'archiveprefix?', 'primaryclass?', 'month?', 'publisher?', 'organization?', 'doi?', 'howpublished?', 'note?', 'pages?', 'number?', 'volume?'], ); # See https://research.arizona.edu/faq/what-do-you-mean-when-you-say-use-title-case-proposalproject-titles @@ -601,6 +601,35 @@ sub fix_number { return $value; } +sub fix_month { + my ($value) = @_; + my %months = ( + '1' => 'jan', + '2' => 'feb', + '3' => 'mar', + '4' => 'apr', + '5' => 'may', + '6' => 'jun', + '7' => 'jul', + '8' => 'aug', + '9' => 'sep', + '10' => 'oct', + '11' => 'nov', + '12' => 'dec', + ); + $value =~ s/^0+//g; + if ($value =~ /^11|12|[0-9]$/) { + $value = $months{$value}; + } else { + my %rev = reverse %months; + my $lc = substr(lc($value), 0, 3); + if (exists $rev{$lc}) { + $value = $lc; + } + } + return $value; +} + sub fix_capitalization { my ($value) = @_; my @words = split(/\s+/, $value); diff --git a/perl-tests/fixing.pl b/perl-tests/fixing.pl index dfde296..4c8c1ba 100755 --- a/perl-tests/fixing.pl +++ b/perl-tests/fixing.pl @@ -72,6 +72,13 @@ package bibcop; fixes('number', '007', '7'); fixes('number', '16', '16'); +fixes('month', '02', 'feb'); +fixes('month', 'January', 'jan'); +fixes('month', 'Dec', 'dec'); +fixes('month', '9', 'sep'); +fixes('month', 'mar', 'mar'); +fixes('month', 'something', 'something'); + sub fixes { my ($tag, $before, $expected) = @_; my $fixer = "fix_$tag";