| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
697
|
use 5.008; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
36
|
|
|
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
25
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
41
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Business::Address::POBox; |
|
6
|
|
|
|
|
|
|
BEGIN { |
|
7
|
1
|
|
|
1
|
|
22
|
$Business::Address::POBox::VERSION = '1.101230'; |
|
8
|
|
|
|
|
|
|
} |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Check whether an address looks like a P.O.Box |
|
11
|
1
|
|
|
1
|
|
907
|
use String::BlackWhiteList; |
|
|
1
|
|
|
|
|
51500
|
|
|
|
1
|
|
|
|
|
11
|
|
|
12
|
1
|
|
|
1
|
|
58
|
use parent qw(Class::Accessor::Complex Class::Accessor::Constructor); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
13
|
|
|
|
|
|
|
__PACKAGE__->mk_constructor->mk_object_accessors( |
|
14
|
|
|
|
|
|
|
'String::BlackWhiteList' => 'matcher') |
|
15
|
|
|
|
|
|
|
->mk_array_accessors(qw(blacklist whitelist)); |
|
16
|
1
|
|
|
|
|
377
|
use constant DEFAULTS => ( |
|
17
|
|
|
|
|
|
|
blacklist => [ |
|
18
|
|
|
|
|
|
|
'\b(BOX|POB|POST(BOX|SCHACHTEL|FACH|LAGERND|BUS)?|POBOX)\b', |
|
19
|
|
|
|
|
|
|
'\b(P\.?\s*O\.?(\s*B(\.|OX))?)\b', |
|
20
|
|
|
|
|
|
|
'(^|\b)P\.?F\.?(-|\s+)\d', |
|
21
|
|
|
|
|
|
|
], |
|
22
|
|
|
|
|
|
|
whitelist => [ |
|
23
|
|
|
|
|
|
|
'Pf(-|\s+)\D', |
|
24
|
|
|
|
|
|
|
'\b((Alte|An\s+der(\s+alten)?)\s+Post|Post(-|\s+)(Road|Rd|Street|St|Avenue|Av|Alley|Drive|Grove|Walk|Parkway|Row|Lane|Bridge|Boulevard|Square|Garden|Strasse|Gasse|Allee|Platz))\b', |
|
25
|
|
|
|
|
|
|
], |
|
26
|
1
|
|
|
1
|
|
10173
|
); |
|
|
1
|
|
|
|
|
2
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub init { |
|
29
|
69
|
|
|
69
|
1
|
39700
|
my $self = shift; |
|
30
|
69
|
|
|
|
|
148
|
$self->update; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub update { |
|
34
|
69
|
|
|
69
|
1
|
75
|
my $self = shift; |
|
35
|
69
|
|
|
|
|
161
|
for ($self->matcher) { |
|
36
|
69
|
|
|
|
|
1589
|
$_->blacklist($self->blacklist); |
|
37
|
69
|
|
|
|
|
2503
|
$_->whitelist($self->whitelist); |
|
38
|
69
|
|
|
|
|
1460
|
$_->update; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub is_pobox { |
|
43
|
69
|
|
|
69
|
1
|
6453
|
my ($self, $text) = @_; |
|
44
|
69
|
100
|
|
|
|
169
|
return 0 if $self->matcher->valid($text); |
|
45
|
33
|
|
|
|
|
1367
|
my $black_re = $self->matcher->black_re; |
|
46
|
|
|
|
|
|
|
# The documentation below explains this mess. |
|
47
|
33
|
|
|
|
|
600
|
$text =~ s/$black_re//gi; |
|
48
|
33
|
|
|
|
|
112
|
$text =~ s/[^\sa-z]//gi; |
|
49
|
33
|
|
|
|
|
95
|
$text =~ s/^\s+|\s+$//g; |
|
50
|
33
|
|
|
|
|
87
|
for my $word (split /\s+/, $text) { |
|
51
|
15
|
100
|
|
|
|
85
|
return 0 if length($word) > 1; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
20
|
|
|
|
|
80
|
return 1; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub is_pobox_relaxed { |
|
57
|
0
|
|
|
0
|
1
|
|
my ($self, $text) = @_; |
|
58
|
0
|
|
|
|
|
|
!$self->matcher->valid_relaxed($text); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
1; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |