line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Date::Extract::ID; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2016-04-08'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
340
|
use 5.010001; |
|
1
|
|
|
|
|
2
|
|
7
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
13
|
|
8
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
176
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
1
|
|
|
1
|
1
|
2
|
my $class = shift; |
12
|
1
|
|
|
|
|
4
|
my %args = ( |
13
|
|
|
|
|
|
|
format => 'DateTime', |
14
|
|
|
|
|
|
|
returns => 'first', |
15
|
|
|
|
|
|
|
prefers => 'nearest', |
16
|
|
|
|
|
|
|
time_zone => 'floating', |
17
|
|
|
|
|
|
|
@_, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
1
|
50
|
|
|
|
3
|
if ($args{format} ne 'DateTime') { |
21
|
0
|
|
|
|
|
0
|
die "Invalid `format` passed to constructor: expected `DateTime'."; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
1
|
50
|
|
|
|
2
|
if ($args{returns} ne 'first') { |
25
|
0
|
|
|
|
|
0
|
die "Invalid `returns` passed to constructor: expected `first'."; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
1
|
50
|
|
|
|
2
|
if ($args{prefers} ne 'nearest') { |
29
|
0
|
|
|
|
|
0
|
die "Invalid `prefers` passed to constructor: expected `nearest'."; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
33
|
|
|
5
|
my $self = bless \%args, ref($class) || $class; |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
2
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub extract { |
38
|
1
|
|
|
1
|
1
|
9
|
state $parser = do { |
39
|
1
|
|
|
|
|
526
|
require DateTime::Format::Alami::ID; |
40
|
1
|
|
|
|
|
7529
|
DateTime::Format::Alami::ID->new; |
41
|
|
|
|
|
|
|
}; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
11
|
my $self = shift; |
44
|
1
|
|
|
|
|
1
|
my $text = shift; |
45
|
1
|
|
|
|
|
2
|
my %args = @_; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# using extract as a class method |
48
|
1
|
50
|
|
|
|
6
|
$self = $self->new |
49
|
|
|
|
|
|
|
if !ref($self); |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
5
|
$parser->parse_datetime($text); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
# ABSTRACT: Extract probable dates from Indonesian text |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |