/
fixing.pl
executable file
·83 lines (73 loc) · 3.39 KB
/
fixing.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/perl
# (The MIT License)
#
# Copyright (c) 2022-2024 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
package bibcop;
use strict;
use warnings;
fixes('author', 'Knuth, Donald E', 'Knuth, Donald E.');
fixes('author', 'Knuth, Donald E and Duane, Bibby', 'Knuth, Donald E. and Duane, Bibby');
fixes('author', ' Knuth, Donald E and others ', 'Knuth, Donald E. and others');
fixes('author', 'Knuth, Donald E.', 'Knuth, Donald E.');
fixes('author', 'Jerome, K Jerome', 'Jerome, K. Jerome');
fixes('author', 'Landin, Peter J.', 'Landin, Peter J.');
fixes('author', 'Brandon, Lucia', 'Brandon, Lucia');
fixes('author', 'Lucia Brandon', 'Brandon, Lucia');
fixes('author', 'Peter J. Landin', 'Landin, Peter J.');
fixes('title', 'The TeX Book', 'The TeX Book');
fixes('title', 'Executing A program On The MIT architecture', 'Executing a Program on the MIT Architecture');
fixes('title', 'Executing a program on the MIT Tagged-token Dataflow architecture', 'Executing a Program on the MIT Tagged-Token Dataflow Architecture');
fixes('booktitle', 'Proceedings Of IEEE Symposium On Art', 'Proceedings of Symposium on Art');
fixes('booktitle', 'Symposium on Computers', 'Proceedings of the Symposium on Computers');
fixes('booktitle', 'Proceedings of the 2014 7th Conference', 'Proceedings of the 7th Conference');
fixes('booktitle', 'Proceedings of the 7th ACM/IEEE Conference', 'Proceedings of the 7th Conference');
fixes('publisher', 'ACM New York, NY, USA', 'ACM');
fixes('publisher', 'ACME', 'ACME');
fixes('publisher', 'IEEE Computer Society', 'IEEE');
fixes('publisher', 'IEEE-Society', 'IEEE');
fixes('publisher', 'IEEEth', 'IEEEth');
fixes('pages', '13', '13');
fixes('pages', '13-', '13');
fixes('pages', '13--', '13');
fixes('pages', '-13', '13');
fixes('pages', '--13', '13');
fixes('pages', 'abc1', 'abc1');
fixes('pages', '196--230', '196--230');
fixes('pages', '100-110', '100--110');
fixes('pages', '117–128', '117--128');
fixes('pages', '2---33', '2--33');
fixes('pages', '22—23', '22--23');
fixes('pages', '05---07', '5--7');
fixes('pages', '42---13', '13--42');
fixes('number', '02', '2');
fixes('number', '007', '7');
fixes('number', '16', '16');
sub fixes {
my ($tag, $before, $expected) = @_;
my $fixer = "fix_$tag";
no strict 'refs';
my $after = $fixer->($before);
if ($after ne $expected) {
print "Didn't fix \"$before\" into \"$expected\", but into \"$after\" instead\n";
exit 1;
}
}
1;