| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MARC::Convert::Wikidata::Utils; |
|
2
|
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
121571
|
use base qw(Exporter); |
|
|
21
|
|
|
|
|
188
|
|
|
|
21
|
|
|
|
|
2782
|
|
|
4
|
21
|
|
|
21
|
|
148
|
use strict; |
|
|
21
|
|
|
|
|
56
|
|
|
|
21
|
|
|
|
|
882
|
|
|
5
|
21
|
|
|
21
|
|
169
|
use warnings; |
|
|
21
|
|
|
|
|
70
|
|
|
|
21
|
|
|
|
|
829
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
21
|
|
|
21
|
|
128
|
use List::Util qw(none); |
|
|
21
|
|
|
|
|
52
|
|
|
|
21
|
|
|
|
|
2688
|
|
|
8
|
21
|
|
|
21
|
|
7929
|
use Readonly; |
|
|
21
|
|
|
|
|
58201
|
|
|
|
21
|
|
|
|
|
1101
|
|
|
9
|
21
|
|
|
21
|
|
9436
|
use Roman; |
|
|
21
|
|
|
|
|
17013
|
|
|
|
21
|
|
|
|
|
1364
|
|
|
10
|
21
|
|
|
21
|
|
6419
|
use Unicode::UTF8 qw(decode_utf8); |
|
|
21
|
|
|
|
|
6449
|
|
|
|
21
|
|
|
|
|
71279
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(clean_cover clean_date clean_edition_number |
|
13
|
|
|
|
|
|
|
clean_number_of_pages clean_oclc clean_publication_date clean_publisher_name |
|
14
|
|
|
|
|
|
|
clean_publisher_place clean_series_name clean_series_ordinal clean_subtitle |
|
15
|
|
|
|
|
|
|
clean_title); |
|
16
|
|
|
|
|
|
|
Readonly::Array our @COVERS => qw(hardback paperback); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = 0.02; |
|
19
|
|
|
|
|
|
|
our $DEBUG = 0; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub clean_cover { |
|
22
|
13
|
|
|
13
|
1
|
6094
|
my $cover = shift; |
|
23
|
|
|
|
|
|
|
|
|
24
|
13
|
50
|
|
|
|
40
|
if (! defined $cover) { |
|
25
|
0
|
|
|
|
|
0
|
return; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
13
|
|
|
|
|
24
|
my $ret_cover = $cover; |
|
29
|
13
|
|
|
|
|
100
|
$ret_cover =~ s/\s*:\s*$//ms; |
|
30
|
13
|
|
|
|
|
62
|
$ret_cover =~ s/^\s*//ms; |
|
31
|
13
|
|
|
|
|
61
|
$ret_cover =~ s/^\(\s*//ms; |
|
32
|
13
|
|
|
|
|
68
|
$ret_cover =~ s/\s*\)$//ms; |
|
33
|
13
|
|
|
|
|
46
|
my $c = decode_utf8('(v|V)áz'); |
|
34
|
13
|
|
|
|
|
135
|
$ret_cover =~ s/^$c\.?$/hardback/ms; |
|
35
|
13
|
|
|
|
|
38
|
$c = decode_utf8('(v|V)ázáno'); |
|
36
|
13
|
|
|
|
|
69
|
$ret_cover =~ s/^$c$/hardback/ms; |
|
37
|
13
|
|
|
|
|
65
|
$c = decode_utf8('(b|B)rož'); |
|
38
|
13
|
|
|
|
|
90
|
$ret_cover =~ s/^$c\.?$/paperback/ms; |
|
39
|
13
|
|
|
|
|
34
|
$c = decode_utf8('(b|B)rožováno'); |
|
40
|
13
|
|
|
|
|
73
|
$ret_cover =~ s/^$c$/paperback/ms; |
|
41
|
|
|
|
|
|
|
|
|
42
|
13
|
50
|
|
18
|
|
97
|
if (none { $ret_cover eq $_ } @COVERS) { |
|
|
18
|
|
|
|
|
251
|
|
|
43
|
0
|
0
|
|
|
|
0
|
if ($DEBUG) { |
|
44
|
0
|
|
|
|
|
0
|
warn "Book cover '$ret_cover' couldn't clean."; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
0
|
|
|
|
|
0
|
$ret_cover = undef; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
13
|
|
|
|
|
79
|
return $ret_cover; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub clean_date { |
|
53
|
17
|
|
|
17
|
1
|
3167
|
my $date = shift; |
|
54
|
|
|
|
|
|
|
|
|
55
|
17
|
100
|
|
|
|
54
|
if (! defined $date) { |
|
56
|
1
|
|
|
|
|
10
|
return; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
16
|
100
|
|
|
|
38
|
if (! $date) { |
|
59
|
1
|
|
|
|
|
4
|
return; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
15
|
|
|
|
|
236
|
my $months_hr = { |
|
63
|
|
|
|
|
|
|
'leden' => '01', |
|
64
|
|
|
|
|
|
|
decode_utf8('únor') => '02', |
|
65
|
|
|
|
|
|
|
decode_utf8('březen') => '03', |
|
66
|
|
|
|
|
|
|
'duben' => '04', |
|
67
|
|
|
|
|
|
|
decode_utf8('květen') => '05', |
|
68
|
|
|
|
|
|
|
decode_utf8('červen') => '06', |
|
69
|
|
|
|
|
|
|
decode_utf8('červenec') => '07', |
|
70
|
|
|
|
|
|
|
'srpen' => '08', |
|
71
|
|
|
|
|
|
|
decode_utf8('září') => '09', |
|
72
|
|
|
|
|
|
|
decode_utf8('říjen') => '10', |
|
73
|
|
|
|
|
|
|
'listopad' => '11', |
|
74
|
|
|
|
|
|
|
'prosinec' => '12', |
|
75
|
|
|
|
|
|
|
}; |
|
76
|
|
|
|
|
|
|
|
|
77
|
15
|
|
|
|
|
34
|
my $ret_date = $date; |
|
78
|
15
|
|
|
|
|
23
|
foreach my $month (keys %{$months_hr}) { |
|
|
15
|
|
|
|
|
83
|
|
|
79
|
180
|
|
|
|
|
2844
|
$ret_date =~ s/^(\d{4})\s*$month\s*(\d+)\.$/$1-$months_hr->{$month}-$2/ms; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
15
|
|
|
|
|
87
|
my $bk = decode_utf8('př. Kr.'); |
|
82
|
15
|
|
|
|
|
125
|
$ret_date =~ s/^(\d+)\s*$bk/-$1/ms; |
|
83
|
15
|
|
|
|
|
52
|
$ret_date =~ s/\s*\.$//ms; |
|
84
|
|
|
|
|
|
|
|
|
85
|
15
|
50
|
|
|
|
113
|
if ($ret_date !~ m/^\-?\d+(\-\d+)?(\-\d+)?$/ms) { |
|
86
|
0
|
0
|
|
|
|
0
|
if ($DEBUG) { |
|
87
|
0
|
|
|
|
|
0
|
warn "Date '$date' couldn't clean."; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
0
|
|
|
|
|
0
|
$ret_date = undef; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
15
|
|
|
|
|
96
|
return $ret_date; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub clean_edition_number { |
|
96
|
52
|
|
|
52
|
1
|
29637
|
my $edition_number = shift; |
|
97
|
|
|
|
|
|
|
|
|
98
|
52
|
100
|
|
|
|
150
|
if (! defined $edition_number) { |
|
99
|
1
|
|
|
|
|
2
|
return; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
51
|
|
|
|
|
98
|
my $ret_edition_number = $edition_number; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Remove [] on begin and end. |
|
105
|
51
|
|
|
|
|
111
|
$ret_edition_number = _remove_square_brackets($ret_edition_number); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Remove trailing whitespace |
|
108
|
51
|
|
|
|
|
112
|
$ret_edition_number = _remove_trailing_whitespace($ret_edition_number); |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Remove special meanings. |
|
111
|
51
|
|
|
|
|
145
|
$ret_edition_number =~ s/,//msg; |
|
112
|
51
|
|
|
|
|
157
|
$ret_edition_number =~ s/\s+a\s+//ms; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Edition. |
|
115
|
51
|
|
|
|
|
141
|
my $v1 = decode_utf8('Vydání'); |
|
116
|
51
|
|
|
|
|
100
|
my $v2 = decode_utf8('vydání'); |
|
117
|
51
|
|
|
|
|
658
|
$ret_edition_number =~ s/\s*(Vyd\.|vyd\.|$v1|$v2|Vydanie|vyd)//gx; |
|
118
|
|
|
|
|
|
|
|
|
119
|
51
|
|
|
|
|
140
|
$ret_edition_number =~ s/\s*rozmn\.//ms; |
|
120
|
51
|
|
|
|
|
122
|
my $re = decode_utf8('souborné'); |
|
121
|
51
|
|
|
|
|
191
|
$ret_edition_number =~ s/\s*$re//ms; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# Authorized. |
|
124
|
51
|
|
|
|
|
106
|
$ret_edition_number =~ s/\s*aut\.//ms; |
|
125
|
51
|
|
|
|
|
85
|
$ret_edition_number =~ s/\s*autoris\.//ms; |
|
126
|
51
|
|
|
|
|
87
|
$ret_edition_number =~ s/\s*autoriz\.//ms; |
|
127
|
51
|
|
|
|
|
130
|
$re = decode_utf8('autorisované'); |
|
128
|
51
|
|
|
|
|
165
|
$ret_edition_number =~ s/\s*$re//ms; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# Extended. |
|
131
|
51
|
|
|
|
|
125
|
$re = decode_utf8('přeprac'); |
|
132
|
51
|
|
|
|
|
195
|
$ret_edition_number =~ s/\s*$re\.//ms; |
|
133
|
51
|
|
|
|
|
119
|
$re = decode_utf8('přepracované'); |
|
134
|
51
|
|
|
|
|
208
|
$ret_edition_number =~ s/\s*$re//ms; |
|
135
|
51
|
|
|
|
|
90
|
$ret_edition_number =~ s/\s*aktualiz\.//ms; |
|
136
|
51
|
|
|
|
|
106
|
$re = decode_utf8('aktualizované'); |
|
137
|
51
|
|
|
|
|
209
|
$ret_edition_number =~ s/\s*$re//ms; |
|
138
|
51
|
|
|
|
|
109
|
$ret_edition_number =~ s/\s*nezm\.//ms; |
|
139
|
51
|
|
|
|
|
125
|
$re = decode_utf8('rozšířené'); |
|
140
|
51
|
|
|
|
|
161
|
$ret_edition_number =~ s/\s*$re//ms; |
|
141
|
51
|
|
|
|
|
123
|
$re = decode_utf8('rozš'); |
|
142
|
51
|
|
|
|
|
397
|
$ret_edition_number =~ s/\s*$re\.?//ms; |
|
143
|
51
|
|
|
|
|
122
|
$ret_edition_number =~ s/\s*dopl\.//ms; |
|
144
|
51
|
|
|
|
|
105
|
$ret_edition_number =~ s/\s*dopln\.//ms; |
|
145
|
51
|
|
|
|
|
108
|
$re = decode_utf8('doplněné'); |
|
146
|
51
|
|
|
|
|
161
|
$ret_edition_number =~ s/\s*$re//ms; |
|
147
|
51
|
|
|
|
|
115
|
$re = decode_utf8('upravené'); |
|
148
|
51
|
|
|
|
|
166
|
$ret_edition_number =~ s/\s*$re//ms; |
|
149
|
51
|
|
|
|
|
119
|
$ret_edition_number =~ s/\s*upr\.//ms; |
|
150
|
51
|
|
|
|
|
86
|
$ret_edition_number =~ s/\s*opr\.//ms; |
|
151
|
51
|
|
|
|
|
105
|
$re = decode_utf8('revidované'); |
|
152
|
51
|
|
|
|
|
165
|
$ret_edition_number =~ s/\s*$re//ms; |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# Czech. |
|
155
|
51
|
|
|
|
|
117
|
$re = decode_utf8('(v|V) českém jazyce'); |
|
156
|
51
|
|
|
|
|
223
|
$ret_edition_number =~ s/\s*$re//ms; |
|
157
|
51
|
|
|
|
|
126
|
$re = decode_utf8('(Č|č)eské'); |
|
158
|
51
|
|
|
|
|
207
|
$ret_edition_number =~ s/\s*$re//ms; |
|
159
|
51
|
|
|
|
|
117
|
$re = decode_utf8('(Č|č)es\.'); |
|
160
|
51
|
|
|
|
|
194
|
$ret_edition_number =~ s/\s*$re//ms; |
|
161
|
51
|
|
|
|
|
130
|
$re = decode_utf8('(v|V) češtině\s*'); |
|
162
|
51
|
|
|
|
|
229
|
$ret_edition_number =~ s/\s*$re//ms; |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
# With illustration. |
|
165
|
51
|
|
|
|
|
116
|
$re = decode_utf8('s vyobrazeními'); |
|
166
|
51
|
|
|
|
|
245
|
$ret_edition_number =~ s/\s*$re//ms; |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# Remove trailing whitespace |
|
169
|
51
|
|
|
|
|
104
|
$ret_edition_number = _remove_trailing_whitespace($ret_edition_number); |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# Rewrite number in Czech to number. |
|
172
|
51
|
|
|
|
|
1286
|
my $dict_hr = { |
|
173
|
|
|
|
|
|
|
decode_utf8('První') => 1, |
|
174
|
|
|
|
|
|
|
decode_utf8('první') => 1, |
|
175
|
|
|
|
|
|
|
decode_utf8('prvé') => 1, |
|
176
|
|
|
|
|
|
|
decode_utf8('Druhé') => 2, |
|
177
|
|
|
|
|
|
|
decode_utf8('druhé') => 2, |
|
178
|
|
|
|
|
|
|
decode_utf8('Třetí') => 3, |
|
179
|
|
|
|
|
|
|
decode_utf8('třetí') => 3, |
|
180
|
|
|
|
|
|
|
decode_utf8('Čtvrté') => 4, |
|
181
|
|
|
|
|
|
|
decode_utf8('čtvrté') => 4, |
|
182
|
|
|
|
|
|
|
decode_utf8('Páté') => 5, |
|
183
|
|
|
|
|
|
|
decode_utf8('páté') => 5, |
|
184
|
|
|
|
|
|
|
decode_utf8('Šesté') => 6, |
|
185
|
|
|
|
|
|
|
decode_utf8('šesté') => 6, |
|
186
|
|
|
|
|
|
|
decode_utf8('Sedmé') => 7, |
|
187
|
|
|
|
|
|
|
decode_utf8('sedmé') => 7, |
|
188
|
|
|
|
|
|
|
decode_utf8('Osmé') => 8, |
|
189
|
|
|
|
|
|
|
decode_utf8('osmé') => 8, |
|
190
|
|
|
|
|
|
|
decode_utf8('Deváté') => 9, |
|
191
|
|
|
|
|
|
|
decode_utf8('deváté') => 9, |
|
192
|
|
|
|
|
|
|
decode_utf8('Desáté') => 10, |
|
193
|
|
|
|
|
|
|
decode_utf8('desáté') => 10, |
|
194
|
|
|
|
|
|
|
decode_utf8('Dvacáté') => 20, |
|
195
|
|
|
|
|
|
|
decode_utf8('dvacáté') => 20, |
|
196
|
|
|
|
|
|
|
}; |
|
197
|
51
|
|
|
|
|
100
|
foreach my $origin (keys %{$dict_hr}) { |
|
|
51
|
|
|
|
|
391
|
|
|
198
|
1173
|
|
|
|
|
13471
|
$ret_edition_number =~ s/\s*$origin\s*/$dict_hr->{$origin}/ms; |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
# Remove dots. |
|
202
|
51
|
|
|
|
|
396
|
$ret_edition_number =~ s/\s*\.\s*//ms; |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# Remove : |
|
205
|
51
|
|
|
|
|
132
|
$ret_edition_number =~ s/\s*:\s*//ms; |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# Rename roman to arabic |
|
208
|
51
|
100
|
|
|
|
168
|
if (isroman($ret_edition_number)) { |
|
209
|
3
|
|
|
|
|
31
|
$ret_edition_number = arabic($ret_edition_number); |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
51
|
100
|
|
|
|
736
|
if ($ret_edition_number !~ m/^\d+$/ms) { |
|
213
|
4
|
50
|
|
|
|
24
|
if ($DEBUG) { |
|
214
|
0
|
|
|
|
|
0
|
warn "Edition number '$edition_number' couldn't clean ($ret_edition_number)."; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
4
|
|
|
|
|
12
|
$ret_edition_number = undef; |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
51
|
|
|
|
|
459
|
return $ret_edition_number; |
|
220
|
|
|
|
|
|
|
} |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub clean_number_of_pages { |
|
223
|
11
|
|
|
11
|
1
|
3680
|
my $number_of_pages = shift; |
|
224
|
|
|
|
|
|
|
|
|
225
|
11
|
50
|
|
|
|
41
|
if (! defined $number_of_pages) { |
|
226
|
0
|
|
|
|
|
0
|
return; |
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
|
|
229
|
11
|
|
|
|
|
25
|
my $ret_number_of_pages = $number_of_pages; |
|
230
|
11
|
|
|
|
|
47
|
$ret_number_of_pages =~ s/^\[(\d+)\]/$1/ms; |
|
231
|
11
|
|
|
|
|
82
|
$ret_number_of_pages =~ s/^(\d+)\s*(s\.|stran).*$/$1/ms; |
|
232
|
|
|
|
|
|
|
|
|
233
|
11
|
50
|
|
|
|
70
|
if ($ret_number_of_pages !~ m/^\d+$/ms) { |
|
234
|
0
|
0
|
|
|
|
0
|
if ($DEBUG) { |
|
235
|
0
|
|
|
|
|
0
|
warn "Number of pages '$number_of_pages' couldn't clean."; |
|
236
|
|
|
|
|
|
|
} |
|
237
|
0
|
|
|
|
|
0
|
$ret_number_of_pages = undef; |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
11
|
|
|
|
|
33
|
return $ret_number_of_pages; |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sub clean_oclc { |
|
244
|
5
|
|
|
5
|
1
|
122
|
my $oclc = shift; |
|
245
|
|
|
|
|
|
|
|
|
246
|
5
|
50
|
|
|
|
20
|
if (! defined $oclc) { |
|
247
|
0
|
|
|
|
|
0
|
return; |
|
248
|
|
|
|
|
|
|
} |
|
249
|
|
|
|
|
|
|
|
|
250
|
5
|
|
|
|
|
11
|
my $ret_oclc = $oclc; |
|
251
|
5
|
|
|
|
|
25
|
$ret_oclc =~ s/^\(OCoLC\)//ms; |
|
252
|
|
|
|
|
|
|
|
|
253
|
5
|
|
|
|
|
21
|
return $ret_oclc; |
|
254
|
|
|
|
|
|
|
} |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub clean_publication_date { |
|
257
|
12
|
|
|
12
|
1
|
7034
|
my $publication_date = shift; |
|
258
|
|
|
|
|
|
|
|
|
259
|
12
|
|
|
|
|
36
|
my $ret_publication_date = $publication_date; |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
# Remove [] on begin and end. |
|
262
|
12
|
|
|
|
|
37
|
$ret_publication_date = _remove_square_brackets($ret_publication_date); |
|
263
|
|
|
|
|
|
|
|
|
264
|
12
|
|
|
|
|
46
|
my $option; |
|
265
|
12
|
100
|
100
|
|
|
96
|
if ($ret_publication_date =~ s/^c(.*)$/$1/ms |
|
266
|
|
|
|
|
|
|
|| $ret_publication_date =~ s/^(.*)\?$/$1/ms) { |
|
267
|
|
|
|
|
|
|
|
|
268
|
4
|
|
|
|
|
10
|
$option = 'circa'; |
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
|
|
271
|
12
|
100
|
100
|
|
|
95
|
if ($ret_publication_date !~ m/^\d+$/ms |
|
272
|
|
|
|
|
|
|
&& $ret_publication_date !~ m/^\d+\-\d*$/ms) { |
|
273
|
|
|
|
|
|
|
|
|
274
|
1
|
50
|
|
|
|
10
|
if ($DEBUG) { |
|
275
|
0
|
|
|
|
|
0
|
warn "Publication date '$publication_date' couldn't clean."; |
|
276
|
|
|
|
|
|
|
} |
|
277
|
1
|
|
|
|
|
3
|
$ret_publication_date = undef; |
|
278
|
|
|
|
|
|
|
} |
|
279
|
|
|
|
|
|
|
|
|
280
|
12
|
|
|
|
|
69
|
return ($ret_publication_date, $option); |
|
281
|
|
|
|
|
|
|
} |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
sub clean_publisher_name { |
|
284
|
16
|
|
|
16
|
1
|
4263
|
my $publisher_name = shift; |
|
285
|
|
|
|
|
|
|
|
|
286
|
16
|
50
|
|
|
|
45
|
if (! defined $publisher_name) { |
|
287
|
0
|
|
|
|
|
0
|
return; |
|
288
|
|
|
|
|
|
|
} |
|
289
|
|
|
|
|
|
|
|
|
290
|
16
|
|
|
|
|
27
|
my $ret_publisher_name = $publisher_name; |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
# Trailing whitespace on begin and end |
|
293
|
16
|
|
|
|
|
38
|
$ret_publisher_name = _remove_trailing_whitespace($ret_publisher_name); |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
# Separators on the end. |
|
296
|
16
|
|
|
|
|
90
|
$ret_publisher_name =~ s/\s*,$//g; |
|
297
|
16
|
|
|
|
|
59
|
$ret_publisher_name =~ s/\s*:$//g; |
|
298
|
16
|
|
|
|
|
60
|
$ret_publisher_name =~ s/\s*;$//g; |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
# Remove ( from begin and not ending. |
|
301
|
16
|
|
|
|
|
71
|
$ret_publisher_name =~ s/^\(([^\)]+)$/$1/ms; |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
# Remove [] on begin and end. |
|
304
|
16
|
|
|
|
|
54
|
$ret_publisher_name = _remove_square_brackets($ret_publisher_name); |
|
305
|
|
|
|
|
|
|
|
|
306
|
16
|
|
|
|
|
46
|
return $ret_publisher_name; |
|
307
|
|
|
|
|
|
|
} |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
sub clean_publisher_place { |
|
310
|
28
|
|
|
28
|
1
|
12013
|
my $publisher_place = shift; |
|
311
|
|
|
|
|
|
|
|
|
312
|
28
|
50
|
|
|
|
101
|
if (! defined $publisher_place) { |
|
313
|
0
|
|
|
|
|
0
|
return; |
|
314
|
|
|
|
|
|
|
} |
|
315
|
|
|
|
|
|
|
|
|
316
|
28
|
|
|
|
|
877
|
my $dict_hr = { |
|
317
|
|
|
|
|
|
|
'Blansku' => 'Blansko', |
|
318
|
|
|
|
|
|
|
decode_utf8('Č. Budějovice') => decode_utf8('České Budějovice'), |
|
319
|
|
|
|
|
|
|
'Plzni' => decode_utf8('Plzeň'), |
|
320
|
|
|
|
|
|
|
'Praze' => 'Praha', |
|
321
|
|
|
|
|
|
|
decode_utf8('Pardubicích') => 'Pardubice', |
|
322
|
|
|
|
|
|
|
decode_utf8('Brně') => 'Brno', |
|
323
|
|
|
|
|
|
|
decode_utf8('Jičíně') => decode_utf8('Jičín'), |
|
324
|
|
|
|
|
|
|
decode_utf8('Jihlavě') => 'Jihlava', |
|
325
|
|
|
|
|
|
|
decode_utf8('Jimramově') => 'Jimramov', |
|
326
|
|
|
|
|
|
|
decode_utf8('Karlových Varech') => 'Karlovy Vary', |
|
327
|
|
|
|
|
|
|
'Liberci' => 'Liberec', |
|
328
|
|
|
|
|
|
|
'Nymburce' => 'Nymburk', |
|
329
|
|
|
|
|
|
|
'Olomouci' => 'Olomouc', |
|
330
|
|
|
|
|
|
|
decode_utf8('Poděbradech') => decode_utf8('Poděbrady'), |
|
331
|
|
|
|
|
|
|
decode_utf8('Přerově') => decode_utf8('Přerov'), |
|
332
|
|
|
|
|
|
|
decode_utf8('Třebíč na Moravě') => decode_utf8('Třebíč'), |
|
333
|
|
|
|
|
|
|
decode_utf8('Třebíči') => decode_utf8('Třebíč'), |
|
334
|
|
|
|
|
|
|
decode_utf8('Třebíči na Moravě') => decode_utf8('Třebíč'), |
|
335
|
|
|
|
|
|
|
decode_utf8('Ostravě') => 'Ostrava', |
|
336
|
|
|
|
|
|
|
decode_utf8('Řevnicích') => decode_utf8('Řevnice'), |
|
337
|
|
|
|
|
|
|
}; |
|
338
|
|
|
|
|
|
|
|
|
339
|
28
|
|
|
|
|
64
|
my $ret_publisher_place = $publisher_place; |
|
340
|
|
|
|
|
|
|
|
|
341
|
28
|
|
|
|
|
141
|
$ret_publisher_place =~ s/\s+$//g; |
|
342
|
28
|
|
|
|
|
99
|
$ret_publisher_place =~ s/\s*:$//g; |
|
343
|
28
|
|
|
|
|
63
|
$ret_publisher_place =~ s/\s*;$//g; |
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
# [V Praze] |
|
346
|
28
|
|
|
|
|
73
|
$ret_publisher_place =~ s/^\[(.*?)\]?$/$1/ms; |
|
347
|
|
|
|
|
|
|
|
|
348
|
28
|
|
|
|
|
85
|
$ret_publisher_place =~ s/^V\s+//ms; |
|
349
|
|
|
|
|
|
|
|
|
350
|
28
|
|
|
|
|
58
|
foreach my $origin (keys %{$dict_hr}) { |
|
|
28
|
|
|
|
|
172
|
|
|
351
|
560
|
|
|
|
|
5021
|
$ret_publisher_place =~ s/^$origin$/$dict_hr->{$origin}/ms; |
|
352
|
|
|
|
|
|
|
} |
|
353
|
|
|
|
|
|
|
|
|
354
|
28
|
|
|
|
|
109
|
$ret_publisher_place =~ s/^V\s+([\s\w]+)$/$1/ms; |
|
355
|
|
|
|
|
|
|
# [Praha] |
|
356
|
28
|
|
|
|
|
66
|
$ret_publisher_place =~ s/^\[(.*?)\]$/$1/ms; |
|
357
|
|
|
|
|
|
|
|
|
358
|
28
|
|
|
|
|
179
|
return $ret_publisher_place; |
|
359
|
|
|
|
|
|
|
} |
|
360
|
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
sub clean_series_name { |
|
362
|
6
|
|
|
6
|
1
|
1202
|
my $series_name = shift; |
|
363
|
|
|
|
|
|
|
|
|
364
|
6
|
50
|
|
|
|
21
|
if (! defined $series_name) { |
|
365
|
0
|
|
|
|
|
0
|
return; |
|
366
|
|
|
|
|
|
|
} |
|
367
|
|
|
|
|
|
|
|
|
368
|
6
|
|
|
|
|
27
|
my $ret_series_name = $series_name; |
|
369
|
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
# Trailing whitespace on begin and end |
|
371
|
6
|
|
|
|
|
28
|
$ret_series_name = _remove_trailing_whitespace($ret_series_name); |
|
372
|
|
|
|
|
|
|
|
|
373
|
6
|
|
|
|
|
98
|
$ret_series_name =~ s/\s*;$//g; |
|
374
|
6
|
|
|
|
|
28
|
$ret_series_name =~ s/\s*:$//g; |
|
375
|
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
# Remove [] on begin and end. |
|
377
|
6
|
|
|
|
|
41
|
$ret_series_name = _remove_square_brackets($ret_series_name); |
|
378
|
|
|
|
|
|
|
|
|
379
|
6
|
|
|
|
|
26
|
return $ret_series_name; |
|
380
|
|
|
|
|
|
|
} |
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
sub clean_series_ordinal { |
|
383
|
16
|
|
|
16
|
1
|
7418
|
my $series_ordinal = shift; |
|
384
|
|
|
|
|
|
|
|
|
385
|
16
|
50
|
|
|
|
43
|
if (! defined $series_ordinal) { |
|
386
|
0
|
|
|
|
|
0
|
return; |
|
387
|
|
|
|
|
|
|
} |
|
388
|
|
|
|
|
|
|
|
|
389
|
16
|
|
|
|
|
30
|
my $ret_series_ordinal = $series_ordinal; |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
# Trailing whitespace on begin and end |
|
392
|
16
|
|
|
|
|
38
|
$ret_series_ordinal = _remove_trailing_whitespace($ret_series_ordinal); |
|
393
|
|
|
|
|
|
|
|
|
394
|
16
|
|
|
|
|
69
|
$ret_series_ordinal =~ s/^(S|s)v\.\s*//g; |
|
395
|
16
|
|
|
|
|
37
|
$ret_series_ordinal =~ s/^svazek\s*//g; |
|
396
|
16
|
|
|
|
|
34
|
$ret_series_ordinal =~ s/\s*svazek$//g; |
|
397
|
|
|
|
|
|
|
|
|
398
|
16
|
|
|
|
|
64
|
my $c = decode_utf8('(č|Č)'); |
|
399
|
16
|
|
|
|
|
239
|
$ret_series_ordinal =~ s/^$c\.\s*//ms; |
|
400
|
16
|
|
|
|
|
62
|
$c = decode_utf8('(č|Č)íslo'); |
|
401
|
16
|
|
|
|
|
128
|
$ret_series_ordinal =~ s/^$c\s*//ms; |
|
402
|
|
|
|
|
|
|
|
|
403
|
16
|
|
|
|
|
54
|
$ret_series_ordinal =~ s/^(\d+)\.$/$1/ms; |
|
404
|
|
|
|
|
|
|
|
|
405
|
16
|
100
|
|
|
|
49
|
if ($ret_series_ordinal =~ m/^(\d+)-(\d+)$/ms) { |
|
406
|
3
|
|
|
|
|
9
|
my $first = $1; |
|
407
|
3
|
|
|
|
|
7
|
my $second = $2; |
|
408
|
3
|
50
|
|
|
|
10
|
if ($second < $first) { |
|
409
|
3
|
|
|
|
|
8
|
my $first_len = length $first; |
|
410
|
3
|
|
|
|
|
7
|
my $second_len = length $second; |
|
411
|
3
|
|
|
|
|
8
|
my $first_addition = substr $first, 0, ($first_len - $second_len); |
|
412
|
3
|
|
|
|
|
13
|
$ret_series_ordinal = $first.'-'.$first_addition.$second; |
|
413
|
|
|
|
|
|
|
} |
|
414
|
|
|
|
|
|
|
} |
|
415
|
|
|
|
|
|
|
|
|
416
|
16
|
|
|
|
|
55
|
return $ret_series_ordinal; |
|
417
|
|
|
|
|
|
|
} |
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
sub clean_subtitle { |
|
420
|
19
|
|
|
19
|
1
|
2512
|
my $subtitle = shift; |
|
421
|
|
|
|
|
|
|
|
|
422
|
19
|
100
|
|
|
|
92
|
if (! defined $subtitle) { |
|
423
|
11
|
|
|
|
|
41
|
return; |
|
424
|
|
|
|
|
|
|
} |
|
425
|
|
|
|
|
|
|
|
|
426
|
8
|
|
|
|
|
21
|
my $ret_subtitle = $subtitle; |
|
427
|
8
|
|
|
|
|
47
|
$ret_subtitle =~ s/\s+$//g; |
|
428
|
8
|
|
|
|
|
41
|
$ret_subtitle =~ s/\/$//g; |
|
429
|
8
|
|
|
|
|
37
|
$ret_subtitle =~ s/\s+$//g; |
|
430
|
8
|
|
|
|
|
31
|
$ret_subtitle =~ s/,$//g; |
|
431
|
|
|
|
|
|
|
|
|
432
|
8
|
|
|
|
|
26
|
return $ret_subtitle; |
|
433
|
|
|
|
|
|
|
} |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
sub clean_title { |
|
436
|
8
|
|
|
8
|
1
|
1701
|
my $title = shift; |
|
437
|
|
|
|
|
|
|
|
|
438
|
8
|
50
|
|
|
|
43
|
if (! defined $title) { |
|
439
|
0
|
|
|
|
|
0
|
return; |
|
440
|
|
|
|
|
|
|
} |
|
441
|
|
|
|
|
|
|
|
|
442
|
8
|
|
|
|
|
21
|
my $ret_title = $title; |
|
443
|
8
|
|
|
|
|
53
|
$ret_title =~ s/\s+$//g; |
|
444
|
8
|
|
|
|
|
30
|
$ret_title =~ s/\s*\/$//g; |
|
445
|
8
|
|
|
|
|
44
|
$ret_title =~ s/\s*\:$//g; |
|
446
|
8
|
|
|
|
|
31
|
$ret_title =~ s/\.$//g; |
|
447
|
|
|
|
|
|
|
|
|
448
|
8
|
|
|
|
|
25
|
return $ret_title; |
|
449
|
|
|
|
|
|
|
} |
|
450
|
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
sub _remove_trailing_whitespace { |
|
452
|
140
|
|
|
140
|
|
235
|
my $string = shift; |
|
453
|
|
|
|
|
|
|
|
|
454
|
140
|
|
|
|
|
417
|
$string =~ s/^\s+//g; |
|
455
|
140
|
|
|
|
|
472
|
$string =~ s/\s+$//g; |
|
456
|
|
|
|
|
|
|
|
|
457
|
140
|
|
|
|
|
288
|
return $string; |
|
458
|
|
|
|
|
|
|
} |
|
459
|
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
sub _remove_square_brackets { |
|
461
|
85
|
|
|
85
|
|
167
|
my $string = shift; |
|
462
|
|
|
|
|
|
|
|
|
463
|
85
|
|
|
|
|
284
|
$string =~ s/^\[\s*(.*?)\s*\]$/$1/ms; |
|
464
|
85
|
|
|
|
|
214
|
$string =~ s/^\[\s*([^\]]+)$/$1/ms; |
|
465
|
|
|
|
|
|
|
|
|
466
|
85
|
|
|
|
|
170
|
return $string; |
|
467
|
|
|
|
|
|
|
} |
|
468
|
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
1; |
|
470
|
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
__END__ |
|
472
|
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
=pod |
|
474
|
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=encoding utf8 |
|
476
|
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
=head1 NAME |
|
478
|
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
MARC::Convert::Wikidata::Utils - Utilities for MARC::Convert::Wikidata. |
|
480
|
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
use MARC::Convert::Wikidata::Utils qw(clean_cover clean_date clean_edition_number clean_number_of_pages clean_oclc clean_publication_date clean_publisher_name clean_publisher_place clean_series_name clean_series_ordinal clean_subtitle clean_title); |
|
484
|
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
my $cleaned_cover = clean_cover($cover); |
|
486
|
|
|
|
|
|
|
my $cleaned_date = clean_date($date); |
|
487
|
|
|
|
|
|
|
my $cleaned_edition_number = clean_edition_number($edition_number); |
|
488
|
|
|
|
|
|
|
my $cleaned_number_of_pages = clean_number_of_pages($number_of_pages); |
|
489
|
|
|
|
|
|
|
my $cleaned_oclc = clean_oclc($oclc); |
|
490
|
|
|
|
|
|
|
my ($cleaned_publication_date, $option) = clean_publication_date($publication_date); |
|
491
|
|
|
|
|
|
|
my $cleaned_publisher_name = clean_publisher_name($publisher); |
|
492
|
|
|
|
|
|
|
my $cleaned_publisher_place = clean_publisher_place($publisher_place); |
|
493
|
|
|
|
|
|
|
my $cleaned_series_name = clean_series_name($series_name); |
|
494
|
|
|
|
|
|
|
my $cleaned_series_ordinal = clean_series_ordinal($series_ordinal); |
|
495
|
|
|
|
|
|
|
my $cleaned_subtitle = clean_subitle($subtitle); |
|
496
|
|
|
|
|
|
|
my $cleaned_title = clean_title($title); |
|
497
|
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=head1 SUBROUTINES |
|
499
|
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=head2 C<clean_cover> |
|
501
|
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
my $cleaned_cover = clean_cover($cover); |
|
503
|
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
Clean book cover in Czech language. |
|
505
|
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
Returns string or undef. |
|
507
|
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
=head2 C<clean_date> |
|
509
|
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
my $cleaned_date = clean_date($date); |
|
511
|
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
Clean date in Czech language. |
|
513
|
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
Returns string or undef. |
|
515
|
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
=head2 C<clean_edition_number> |
|
517
|
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
my $cleaned_edition_number = clean_edition_number($edition_number); |
|
519
|
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
Clean edition number in Czech language. |
|
521
|
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
Returns string or undef. |
|
523
|
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=head2 C<clean_number_of_pages> |
|
525
|
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
my $cleaned_number_of_pages = clean_number_of_pages($number_of_pages); |
|
527
|
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
Clean number of pages in Czech language. |
|
529
|
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
Returns string or undef. |
|
531
|
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
=head2 C<clean_oclc> |
|
533
|
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
my $cleaned_oclc = clean_oclc($oclc); |
|
535
|
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
Clean OCLC number. |
|
537
|
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
Returns string or undef. |
|
539
|
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
=head2 C<clean_publication_date> |
|
541
|
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
my ($cleaned_publication_date, $option) = clean_publication_date($publication_date); |
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
Clean publication date. Returned options could be 'circa' string in case that |
|
545
|
|
|
|
|
|
|
publication date is not precise. |
|
546
|
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
Returns array with string or undef and string. |
|
548
|
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
=head2 C<clean_publisher_name> |
|
550
|
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
my $cleaned_publisher_name = clean_publisher_name($publisher); |
|
552
|
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
Clean publishing house. |
|
554
|
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
Returns string or undef. |
|
556
|
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
=head2 C<clean_publisher_place> |
|
558
|
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
my $cleaned_publisher_place = clean_publisher_place($publisher_place); |
|
560
|
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
Clean place of publication in Czech language. |
|
562
|
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
Returns string or undef. |
|
564
|
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
=head2 C<clean_series_name> |
|
566
|
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
my $cleaned_series_name = clean_series_name($series_name); |
|
568
|
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
Clean series name. |
|
570
|
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
Returns string or undef. |
|
572
|
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
=head2 C<clean_series_ordinal> |
|
574
|
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
my $cleaned_series_ordinal = clean_series_ordinal($series_ordinal); |
|
576
|
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
Clean series ordinal in Czech language. |
|
578
|
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
Returns string or undef. |
|
580
|
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
=head2 C<clean_subtitle> |
|
582
|
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
my $cleaned_subtitle = clean_subtitle($subtitle); |
|
584
|
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
Clean subtitle. |
|
586
|
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
Returns string or undef. |
|
588
|
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
=head2 C<clean_title> |
|
590
|
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
my $cleaned_title = clean_title($title); |
|
592
|
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
Clean title. |
|
594
|
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
Returns string or undef. |
|
596
|
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=head1 EXAMPLE1 |
|
598
|
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
=for comment filename=clean_cover.pl |
|
600
|
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
use strict; |
|
602
|
|
|
|
|
|
|
use warnings; |
|
603
|
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
use MARC::Convert::Wikidata::Utils qw(clean_cover); |
|
605
|
|
|
|
|
|
|
use Unicode::UTF8 qw(decode_utf8 encode_utf8); |
|
606
|
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
my $cover = decode_utf8('(Vázáno) :');; |
|
608
|
|
|
|
|
|
|
my $cleaned_cover = clean_cover($cover); |
|
609
|
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
# Print out. |
|
611
|
|
|
|
|
|
|
print encode_utf8("Cover: $cover\n"); |
|
612
|
|
|
|
|
|
|
print "Cleaned cover: $cleaned_cover\n"; |
|
613
|
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
# Output: |
|
615
|
|
|
|
|
|
|
# Cover: (Vázáno) : |
|
616
|
|
|
|
|
|
|
# Cleaned cover: hardback |
|
617
|
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
=head1 EXAMPLE2 |
|
619
|
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
=for comment filename=clean_date.pl |
|
621
|
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
use strict; |
|
623
|
|
|
|
|
|
|
use warnings; |
|
624
|
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
use MARC::Convert::Wikidata::Utils qw(clean_date); |
|
626
|
|
|
|
|
|
|
use Unicode::UTF8 qw(decode_utf8 encode_utf8); |
|
627
|
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
my $date = decode_utf8('2020 březen 03.'); |
|
629
|
|
|
|
|
|
|
my $cleaned_date = clean_date($date); |
|
630
|
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
# Print out. |
|
632
|
|
|
|
|
|
|
print encode_utf8("Date: $date\n"); |
|
633
|
|
|
|
|
|
|
print "Cleaned date: $cleaned_date\n"; |
|
634
|
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
# Output: |
|
636
|
|
|
|
|
|
|
# Date: 2020 březen 03. |
|
637
|
|
|
|
|
|
|
# Cleaned date: 2020-03-03 |
|
638
|
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
=head1 EXAMPLE3 |
|
640
|
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
=for comment filename=clean_edition_number.pl |
|
642
|
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
use strict; |
|
644
|
|
|
|
|
|
|
use warnings; |
|
645
|
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
use MARC::Convert::Wikidata::Utils qw(clean_edition_number); |
|
647
|
|
|
|
|
|
|
use Unicode::UTF8 qw(decode_utf8 encode_utf8); |
|
648
|
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
my $edition_number = decode_utf8('Druhé vydání'); |
|
650
|
|
|
|
|
|
|
my $cleaned_edition_number = clean_edition_number($edition_number); |
|
651
|
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
# Print out. |
|
653
|
|
|
|
|
|
|
print encode_utf8("Edition number: $edition_number\n"); |
|
654
|
|
|
|
|
|
|
print "Cleaned edition number: $cleaned_edition_number\n"; |
|
655
|
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
# Output: |
|
657
|
|
|
|
|
|
|
# Edition number: Druhé vydání |
|
658
|
|
|
|
|
|
|
# Cleaned edition number: 2 |
|
659
|
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
661
|
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
L<Exporter>, |
|
663
|
|
|
|
|
|
|
L<List::Util>, |
|
664
|
|
|
|
|
|
|
L<Readonly>, |
|
665
|
|
|
|
|
|
|
L<Roman>, |
|
666
|
|
|
|
|
|
|
L<Unicode::UTF8>. |
|
667
|
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
669
|
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/MARC-Convert-Wikidata> |
|
671
|
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
=head1 AUTHOR |
|
673
|
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
|
675
|
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
L<http://skim.cz> |
|
677
|
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
679
|
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
© 2021-2023 Michal Josef Špaček |
|
681
|
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
BSD 2-Clause License |
|
683
|
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
=head1 VERSION |
|
685
|
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
0.02 |
|
687
|
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
=cut |