mirror of
https://codeberg.org/scip/leo.git
synced 2025-12-16 20:21:03 +01:00
catch no $term
This commit is contained in:
123
Org.pm
123
Org.pm
@@ -7,7 +7,7 @@
|
|||||||
# or service marks of their respective holders.
|
# or service marks of their respective holders.
|
||||||
|
|
||||||
package WWW::Dict::Leo::Org;
|
package WWW::Dict::Leo::Org;
|
||||||
$WWW::Dict::Leo::Org::VERSION = "1.43";
|
$WWW::Dict::Leo::Org::VERSION = "1.44";
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
@@ -24,25 +24,24 @@ sub new {
|
|||||||
my ($class, %param) = @_;
|
my ($class, %param) = @_;
|
||||||
my $type = ref( $class ) || $class;
|
my $type = ref( $class ) || $class;
|
||||||
|
|
||||||
my %settings = (
|
my %settings = (
|
||||||
"-Host" => "pda.leo.org",
|
"-Host" => "pda.leo.org",
|
||||||
"-Port" => 80,
|
"-Port" => 80,
|
||||||
"-UserAgent" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9",
|
"-UserAgent" => "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0",
|
||||||
"-Proxy" => "",
|
"-Proxy" => "",
|
||||||
"-ProxyUser" => "",
|
"-ProxyUser" => "",
|
||||||
"-ProxyPass" => "",
|
"-ProxyPass" => "",
|
||||||
"-Debug" => 0,
|
"-Debug" => 0,
|
||||||
"-SpellTolerance" => "standard", # on, off
|
"-SpellTolerance" => "standard", # on, off
|
||||||
"-Morphology" => "standard", # none, forcedAll
|
"-Morphology" => "standard", # none, forcedAll
|
||||||
"-CharTolerance" => "relaxed", # fuzzy, exact
|
"-CharTolerance" => "relaxed", # fuzzy, exact
|
||||||
"-Language" => "en", # en2de, de2fr, fr2de, de2es, es2de
|
"-Language" => "en", # en2de, de2fr, fr2de, de2es, es2de
|
||||||
|
"data" => {}, # the results
|
||||||
"data" => {}, # the results
|
"section" => [],
|
||||||
"section" => [],
|
"title" => "",
|
||||||
"title" => "",
|
"segments" => [],
|
||||||
"segments" => [],
|
"Maxsize" => 0,
|
||||||
"Maxsize" => 0,
|
"Linecount" => 0,
|
||||||
"Linecount" => 0,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach my $key (keys %param) {
|
foreach my $key (keys %param) {
|
||||||
@@ -58,6 +57,10 @@ sub new {
|
|||||||
sub translate {
|
sub translate {
|
||||||
my($this, $term) = @_;
|
my($this, $term) = @_;
|
||||||
|
|
||||||
|
if (! $term) {
|
||||||
|
croak "No term to translate given!";
|
||||||
|
}
|
||||||
|
|
||||||
my $linecount = 0;
|
my $linecount = 0;
|
||||||
my $maxsize = 0;
|
my $maxsize = 0;
|
||||||
my @match = ();
|
my @match = ();
|
||||||
@@ -459,49 +462,49 @@ Use this method after initialization to connect to dict.leo.org
|
|||||||
and translate the given term. It returns an array of hashes containing
|
and translate the given term. It returns an array of hashes containing
|
||||||
the actual results.
|
the actual results.
|
||||||
|
|
||||||
use WWW::Dict::Leo::Org;
|
use WWW::Dict::Leo::Org;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
my $leo = new WWW::Dict::Leo::Org();
|
my $leo = new WWW::Dict::Leo::Org();
|
||||||
my @matches = $leo->translate("test");
|
my @matches = $leo->translate("test");
|
||||||
print Dumper(\@matches);
|
print Dumper(\@matches);
|
||||||
|
|
||||||
which prints:
|
which prints:
|
||||||
|
|
||||||
$VAR1 = [
|
$VAR1 = [
|
||||||
{
|
{
|
||||||
'data' => [
|
'data' => [
|
||||||
{
|
{
|
||||||
'left' => 'check',
|
'left' => 'check',
|
||||||
'right' => 'der Test'
|
'right' => 'der Test'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'left' => 'quiz (Amer.)',
|
'left' => 'quiz (Amer.)',
|
||||||
'right' => 'der Test <20><> [Schule]'
|
'right' => 'der Test <20><> [Schule]'
|
||||||
],
|
],
|
||||||
'title' => 'Unmittelbare Treffer'
|
'title' => 'Unmittelbare Treffer'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'data' => [
|
'data' => [
|
||||||
{
|
{
|
||||||
'left' => 'to fail a test',
|
'left' => 'to fail a test',
|
||||||
'right' => 'einen Test nicht bestehen'
|
'right' => 'einen Test nicht bestehen'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'left' => 'to test',
|
'left' => 'to test',
|
||||||
'right' => 'Tests macheneinen Test machen'
|
'right' => 'Tests macheneinen Test machen'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'title' => 'Verben und Verbzusammensetzungen'
|
'title' => 'Verben und Verbzusammensetzungen'
|
||||||
},
|
},
|
||||||
'data' => [
|
'data' => [
|
||||||
{
|
{
|
||||||
'left' => 'testing <20>adj.',
|
'left' => 'testing <20>adj.',
|
||||||
'right' => 'im Test'
|
'right' => 'im Test'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'title' => 'Wendungen und Ausdr<64>cke'
|
'title' => 'Wendungen und Ausdr<64>cke'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
You might take a look at the B<leo> script how to process
|
You might take a look at the B<leo> script how to process
|
||||||
@@ -542,6 +545,6 @@ Please don't forget to add debugging output!
|
|||||||
|
|
||||||
=head1 VERSION
|
=head1 VERSION
|
||||||
|
|
||||||
1.43
|
1.44
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|||||||
Reference in New Issue
Block a user