line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
115580
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
152
|
|
2
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
152
|
|
3
|
|
|
|
|
|
|
package Lingua::Metadata; |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
3438
|
use LWP::Simple; |
|
4
|
|
|
|
|
672451
|
|
|
4
|
|
|
|
|
40
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.005'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Returns information about languages. |
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
1896
|
use constant SERVICE_URL => 'http://w2c.martin.majlis.cz/language/'; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
1747
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %cache_iso = (); |
14
|
|
|
|
|
|
|
our %cache_metadata = (); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub get_iso |
18
|
|
|
|
|
|
|
{ |
19
|
14
|
|
|
14
|
1
|
49
|
my $label = shift; |
20
|
|
|
|
|
|
|
|
21
|
14
|
100
|
|
|
|
186
|
if ( ! defined($label) ) { |
22
|
2
|
|
|
|
|
14
|
return; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
12
|
100
|
|
|
|
57
|
if ( ! defined($cache_iso{$label}) ) { |
26
|
11
|
|
|
|
|
34
|
my $url = SERVICE_URL . '?alias=' . $label; |
27
|
11
|
|
|
|
|
63
|
$cache_iso{$label} = get($url); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
12
|
|
|
|
|
1548498
|
return $cache_iso{$label}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get_language_metadata |
35
|
|
|
|
|
|
|
{ |
36
|
8
|
|
|
8
|
1
|
7171
|
my $language = shift; |
37
|
|
|
|
|
|
|
|
38
|
8
|
|
|
|
|
26
|
my %result = (); |
39
|
8
|
|
|
|
|
33
|
my $iso = get_iso($language); |
40
|
|
|
|
|
|
|
|
41
|
8
|
100
|
|
|
|
71
|
if ( ! defined($iso) ) { |
|
|
100
|
|
|
|
|
|
42
|
1
|
|
|
|
|
6
|
return $iso; |
43
|
|
|
|
|
|
|
} elsif ( $iso eq '' ) { |
44
|
1
|
|
|
|
|
10
|
return \%result; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
6
|
|
|
|
|
21
|
my $url = SERVICE_URL . '?action=GET&format=TXT&lang=' . $iso; |
48
|
|
|
|
|
|
|
|
49
|
6
|
100
|
|
|
|
27
|
if ( ! defined($cache_metadata{$iso}) ) { |
50
|
2
|
|
|
|
|
12
|
my $content = get($url); |
51
|
|
|
|
|
|
|
|
52
|
2
|
50
|
|
|
|
166241
|
if ( $content ) { |
53
|
2
|
|
|
|
|
146
|
for my $line ( split(/\n/, $content) ) { |
54
|
86
|
|
|
|
|
116
|
chomp $line; |
55
|
86
|
|
|
|
|
633
|
my @parts = split(/\t/, $line); |
56
|
86
|
|
|
|
|
539
|
$result{$parts[1]} = $parts[2]; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
2
|
|
|
|
|
17
|
$cache_metadata{$iso} = \%result; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
6
|
|
|
|
|
31
|
return $cache_metadata{$iso}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |