| 1 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # Copyleft (l) 2000-2016 Thomas v.D. <tlinden@cpan.org>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # leo may be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # used and distributed under the terms of the GNU General Public License. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # All other brand and product names are trademarks, registered trademarks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # or service marks of their respective holders. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | package WWW::Dict::Leo::Org; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | $WWW::Dict::Leo::Org::VERSION = "1.42"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use English '-no_match_vars'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Carp::Heavy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use IO::Socket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use HTML::TableParser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | sub debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my ($class, %param) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | my $type = ref( $class ) || $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my %settings = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | "-Host" => "pda.leo.org", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | "-Port" => 80, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | "-UserAgent" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | "-Proxy" => "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | "-ProxyUser" => "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | "-ProxyPass" => "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | "-Debug" => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | "-SpellTolerance" => "standard", # on, off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | "-Morphology" => "standard", # none, forcedAll | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | "-CharTolerance" => "relaxed", # fuzzy, exact | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | "-Language" => "en", # en2de, de2fr, fr2de, de2es, es2de | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | "data" => {}, # the results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | "section" => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | "title" => "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | "segments" => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | "Maxsize" => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | "Linecount" => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | foreach my $key (keys %param) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $settings{$key} = $param{$key}; # override defaults | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $self = \%settings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | bless $self, $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | sub translate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | my($this, $term) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
translate: not called CC=25 SCAR=64.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $linecount = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $maxsize = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my @match = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # form var transitions for searchLoc(=translation direction) and lp(=language) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my %lang = ( speak => "ende" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my @langs = qw(en es ru pt fr pl ch it); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ($this->{"-Language"}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # en | fr | ru2en | de2pl etc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # de2, 2de, de are not part of lang spec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if (! grep { $this->{"-Language"} =~ /$_/ } @langs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | croak "Unsupported language: " . $this->{"-Language"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $spec = $this->{"-Language"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if ($spec =~ /(..)2de/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $l = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $this->{"-Language"} = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $lang{speak} = "${l}de"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | elsif ($spec =~ /de2(..)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $l = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $this->{"-Language"} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $lang{speak} = "${l}de"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $lang{speak} = $this->{"-Language"} . 'de'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $this->{"-Language"} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # cut invalid values for parameters or set defaults if unspecified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | my %form = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | spellToler => { mask => [ qw(standard on off) ], val => $this->{"-SpellTolerance"} || "standard" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | deStem => { mask => [ qw(standard none forcedAll) ], val => $this->{"-Morphology"} || "standard" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | cmpType => { mask => [ qw(fuzzy exact relaxed) ], val => $this->{"-CharTolerance"} || "relaxed" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | searchLoc => { mask => [ qw(-1 0 1) ], val => $this->{"-Language"} || "0" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$this->{'-SpellTolerance'} || 'standard'
$this->{'-Morphology'} || 'standard'
$this->{'-CharTolerance'} || 'relaxed'
$this->{'-Language'} || '0'
MC/DC0%0/1
$this->{'-SpellTolerance'} || 'standard'
$this->{'-SpellTolerance'}
MC/DC0%0/1
$this->{'-Morphology'} || 'standard'
$this->{'-Morphology'}
MC/DC0%0/1
$this->{'-CharTolerance'} || 'relaxed'
$this->{'-CharTolerance'}
MC/DC0%0/1
$this->{'-Language'} || '0'
$this->{'-Language'}
Truth table0%0/2
A
A= $this->{'-SpellTolerance'}
Truth table0%0/2
A
A= $this->{'-Morphology'}
Truth table0%0/2
A
A= $this->{'-CharTolerance'}
Truth table0%0/2
A
A= $this->{'-Language'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my @form; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | foreach my $var (keys %form) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if (grep { $form{$var}->{val} eq $_ } @{$form{$var}->{mask}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | push @form, $var . "=" . $form{$var}->{val}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # add language | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | push @form, "lp=$lang{speak}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # process whitespaces | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $query = $term; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $query =~ s/\s\s*/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $query =~ s/\s/\+/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | push @form, "search=$query"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # make the query cgi'ish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $form = join "&", @form; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # store for result caching | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $this->{Form} = $form; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # check for proxy settings and use it if exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # otherwise use direct connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my ($url, $site); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $ip = $this->{"-Host"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $port = $this->{"-Port"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $proxy_user = $this->{"-ProxyUser"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $proxy_pass = $this->{"-ProxyPass"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if ($this->{"-Proxy"}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $proxy = $this->{"-Proxy"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $proxy =~ s/^http:\/\///i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if ($proxy =~ /^(.+):(.+)\@(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # proxy user account | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $proxy_user = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $proxy_pass = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $proxy = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $this->debug( "proxy_user: $proxy_user"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my($host, $pport) = split /:/, $proxy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if ($pport) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $url = "http://$ip:$port/dictQuery/m-vocab/$lang{speak}/de.html"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $port = $pport; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $port = 80; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $ip = $host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $this->debug( "connecting to proxy:", $ip, $port); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $this->debug( "connecting to site:", $ip, "port", $port); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $url = "/dictQuery/m-vocab/$lang{speak}/de.html"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | my $conn = new IO::Socket::INET( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | Proto => "tcp", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | PeerAddr => $ip, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | PeerPort => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | ) or die "Unable to connect to $ip:$port: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $conn->autoflush(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $this->debug( "GET $url?$form HTTP/1.0"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | print $conn "GET $url?$form HTTP/1.0\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # be nice, simulate Konqueror. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | print $conn | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | qq($this->{"-UserAgent"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | Host: $this->{"-Host"}:$this->{"-Port"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | Accept: text/*;q=1.0, image/png;q=1.0, image/jpeg;q=1.0, image/gif;q=1.0, image/*;q=0.8, */*;q=0.5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | Accept-Charset: iso-8859-1;q=1.0, *;q=0.9, utf-8;q=0.8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | Accept-Language: en_US, en\r\n); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if ($this->{"-Proxy"} and $proxy_user) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$this->{"-Proxy"} and $proxy_user
MC/DC0%0/2
$this->{"-Proxy"} and $proxy_user
$this->{"-Proxy"}
$proxy_user
Truth table0%0/3
A and B
A= $this->{"-Proxy"}B= $proxy_user
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # authenticate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # construct the auth header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $coded = encode_base64("$proxy_user:$proxy_pass"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $this->debug( "Proxy-Authorization: Basic $coded"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | print $conn "Proxy-Authorization: Basic $coded\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # finish the request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | print $conn "\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # parse dict.leo.org output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my @line = <$conn>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | close $conn or die "Connection failed: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $this->debug( "connection: done"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $site = join "", @line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | if ($site !~ /HTTP\/1\.(0|1) 200 OK/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if ($site =~ /HTTP\/1\.(0|1) (\d+) /i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # got HTTP error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $err = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if ($err == 407) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | croak "proxy auth required or access denied!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ($site =~ /Leider konnten wir zu Ihrem Suchbegriff/ || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$site =~ /Leider konnten wir zu Ihrem Suchbegriff/ or $site =~ /found no matches for your search/
MC/DC0%0/2
$site =~ /Leider konnten wir zu Ihrem Suchbegriff/ or $site =~ /found no matches for your search/
$site =~ /Leider konnten wir zu Ihrem Suchbegriff/
$site =~ /found no matches for your search/
Truth table0%0/3
A or B
A= $site =~ /Leider konnten wir zu Ihrem Suchbegriff/B= $site =~ /found no matches for your search/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | $site =~ /found no matches for your search/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | croak "got HTTP error $err!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | my @request = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | id => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | row => sub { $this->row(@_); }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | hdr => sub { $this->hdr(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | id => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | hdr => sub { $this->hdr(@_); }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | row => sub { $this->row(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | id => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | hdr => sub { $this->hdr(@_); }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | row => sub { $this->row(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $this->{Linecount} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $p = HTML::TableParser->new( \@request, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | { Decode => 1, Trim => 1, Chomp => 1, DecodeNBSP => 1 } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $site=~s/ /\ \;/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $p->parse($site); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # put the rest on the stack, if any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if (@{$this->{section}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $this->{data}->{ $this->{title} } = $this->{section}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | push @{$this->{segments}}, $this->{title}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # put back in order | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my @matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | foreach my $title (@{$this->{segments}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | push @matches, { title => $title, data => $this->{data}->{$title} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | return @matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | sub hdr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # HTML::TableParser header callback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | my ( $this, $tbl_id, $line_no, $data, $udata ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hdr: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if ($data->[1] && $data->[0] eq $data->[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$data->[1] and $data->[0] eq $data->[1]
MC/DC0%0/2
$data->[1] and $data->[0] eq $data->[1]
$data->[1]
$data->[0] eq $data->[1]
Truth table0%0/3
A and B
A= $data->[1]B= $data->[0] eq $data->[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $this->debug("Probable start of a new section: $data->[1]"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | if (@{$this->{section}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $this->{data}->{ $this->{title} } = $this->{section}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | push @{$this->{segments}}, $this->{title}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $this->{title} = $data->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $this->{section} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | sub row { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # HTML::TableParser data row callback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # divide rows into titles and lang data. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | # we get 2 items (left and right column), if they | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # are equal, it's a segment title, otherwise it's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # segment content. left columns ending in HH:MM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | # are forumposts and ignored as well as rows with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | # empty left cells. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | my ( $this, $tbl_id, $line_no, $data, $udata ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
row: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my $len = length($data->[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | if ($data->[1] && $data->[0] && $data->[0] ne $data->[1] && $data->[0] !~ /\d{2}:\d{2}$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$data->[1] and $data->[0] and $data->[0] ne $data->[1] and not $data->[0] =~ /\d{2}:\d{2}$/
$data->[1] and $data->[0] and $data->[0] ne $data->[1]
$data->[1] and $data->[0]
MC/DC0%0/4
$data->[1] and $data->[0] and $data->[0] ne $data->[1] and not $data->[0] =~ /\d{2}:\d{2}$/
$data->[1]
$data->[0]
$data->[0] ne $data->[1]
not $data->[0] =~ /\d{2}:\d{2}$/
Truth table0%0/5
A and B and C and not(D)
A= $data->[1]B= $data->[0]C= $data->[0] ne $data->[1]D= not $data->[0] =~ /\d{2}:\d{2}$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | if ($len > $this->{Maxsize}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $this->{Maxsize} = $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $this->debug("line: $line_no, left: $data->[0], right: $data->[1]"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | push @{$this->{section}}, { left => $data->[0], right => $data->[1] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $this->{Linecount}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | sub grapheme_length { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | my($this, $str) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grapheme_length: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | while ($str =~ /\X/g) { $count++ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | return $count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | sub maxsize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | my($this) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
maxsize: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | return $this->{Maxsize}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | sub lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | my($this) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lines: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | return $this->{Linecount}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | sub form { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | my($this) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
form: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | return $this->{Form}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | sub debug { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | my($this, $msg) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | if ($this->{"-Debug"}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | print STDERR "%DEBUG: $msg\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | =encoding ISO8859-1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | WWW::Dict::Leo::Org - Interface module to dictionary dict.leo.org | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | use WWW::Dict::Leo::Org; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | my $leo = new WWW::Dict::Leo::Org(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | my @matches = $leo->translate($term); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | B<WWW::Dict::Leo::Org> is a module which connects to the website | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | B<dict.leo.org> and translates the given term. It returns an array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | of hashes. Each hash contains a left side and a right side of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | result entry. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | =head1 OPTIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | B<new()> has several parameters, which can be supplied as a hash. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | All parameters are optional. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | =item I<-Host> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | The hostname of the dict website to use. For the moment only dict.leo.org | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | is supported, which is also the default - therefore changing the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | hostname would not make much sense. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | =item I<-Port> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | The tcp port to use for connecting, the default is 80, you shouldn't | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | change it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | =item I<-UserAgent> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | The user-agent to send to dict.leo.org site. Currently this is the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | default: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | =item I<-Proxy> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | Fully qualified proxy server. Specify as you would do in the well | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | known environment variable B<http_proxy>, example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | -Proxy => "http://192.168.1.1:3128" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | =item I<-ProxyUser> I<-ProxyPass> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | If your proxy requires authentication, use these parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | to specify the credentials. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | =item I<-Debug> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | If enabled (set to 1), prints a lot of debug information to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | stderr, normally only required for developers or to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | report bugs (see below). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | Parameters to control behavior of dict.leo.org: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | =item I<-SpellTolerance> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | Be tolerant to spelling errors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | Default: turned on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | Possible values: on, off. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | =item I<-Morphology> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | Provide morphology information. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | Default: standard. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | Possible values: standard, none, forcedAll. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | =item I<-CharTolerance> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | Allow umlaut alternatives. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | Default: relaxed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | Possible values: fuzzy, exact, relaxed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | =item I<-Language> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | Translation direction. Please note that dict.leo.org always translates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | either to or from german. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | The following languages are supported: english, polish, spanish, portugese | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | russian and chinese. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | You can specify only the country code, or append B<de2> in order to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | force translation to german, or preprend B<de2> in order to translate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | to the other language. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | Valid examples: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | ru to or from russian | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | de2pl to polish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | es2de spanish to german | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | Valid country codes: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | en english | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | es spanish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ru russian | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | pt portugese | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | pl polish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | ch chinese | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | Default: B<en>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | =head2 translate($term) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | Use this method after initialization to connect to dict.leo.org | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | and translate the given term. It returns an array of hashes containing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | the actual results. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | use WWW::Dict::Leo::Org; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | my $leo = new WWW::Dict::Leo::Org(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | my @matches = $leo->translate("test"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | print Dumper(\@matches); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | which prints: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | $VAR1 = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 'data' => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 'left' => 'check', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 'right' => 'der Test' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 'left' => 'quiz (Amer.)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 'right' => 'der Test [Schule]' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 'title' => 'Unmittelbare Treffer' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 'data' => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 'left' => 'to fail a test', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 'right' => 'einen Test nicht bestehen' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 'left' => 'to test', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 'right' => 'Tests macheneinen Test machen' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 'title' => 'Verben und Verbzusammensetzungen' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 'data' => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 'left' => 'testing adj.', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 'right' => 'im Test' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 'title' => 'Wendungen und Ausdrücke' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | You might take a look at the B<leo> script how to process | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | this data. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | =head2 maxsize() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | Returns the size of the largest returned term (left side). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | =head2 lines() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | Returns the number of translation results. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | =head2 form() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | Returns the submitted form uri. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | L<leo> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | WWW::Dict::Leo::Org - Copyright (c) 2007-2016 by Thomas v.D. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | L<http://dict.leo.org/> - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | Copyright (c) 1995-2016 LEO Dictionary Team. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | Thomas v.D. <tlinden@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | =head1 HOW TO REPORT BUGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | Use L<rt.cpan.org> to report bugs, select the queue for B<WWW::Dict::Leo::Org>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | Please don't forget to add debugging output! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 1.42 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||