| 1 |
#!/usr/bin/perl -s |
| 2 |
|
| 3 |
eval 'exec /usr/bin/perl -s -S $0 ${1+"$@"}' |
| 4 |
if 0; # not running under some shell |
| 5 |
|
| 6 |
our ($all); |
| 7 |
|
| 8 |
my $langa = shift; |
| 9 |
my ($l1,$l2) = ($langa =~ m{(.*)\.\.(.*)}); |
| 10 |
die("Usage: $0 l1..l2 thesaurus\n") unless $l1 && $l2; |
| 11 |
|
| 12 |
$l1=uc($l1); |
| 13 |
$l2=uc($l2); |
| 14 |
|
| 15 |
my $thesaurus= shift or die("Usage: $0 l1..l2 thesaurus\n") ; |
| 16 |
|
| 17 |
die("thesaurus $thesaurus not found\n") unless -f $thesaurus; |
| 18 |
|
| 19 |
use Biblio::Thesaurus; |
| 20 |
|
| 21 |
my $obj = thesaurusLoad($thesaurus); |
| 22 |
### open (G,">_bilingue") or die("cant create bilingue"); |
| 23 |
|
| 24 |
print "%encoding ",$obj->{encoding},"\n\n" if defined $obj->{encoding}; |
| 25 |
binmode(STDOUT, $obj->{encoding}.":") if defined $obj->{encoding}; |
| 26 |
|
| 27 |
$obj->downtr( |
| 28 |
{ $l1 => sub { $p1 = $terms[0] ; }, |
| 29 |
$l2 => sub { $p2 = $terms[0] ; }, |
| 30 |
IOF => sub { $cl = join(",",@terms); }, |
| 31 |
# BT => sub { $bt = join(",",@terms); }, |
| 32 |
-eachTerm => sub { |
| 33 |
if(uc($obj->baselang()) eq $l1) {$p1 = $term; } |
| 34 |
if(uc($obj->baselang()) eq $l2) {$p2 = $term; } |
| 35 |
# $cl ||=$bt; |
| 36 |
if ($p1 || $p2){ |
| 37 |
$p1 = "[$l1-$l2 $p2]" unless $p1; |
| 38 |
$p2 = "[$l2-$l1 $p1]" unless $p2; |
| 39 |
if ($all){ print "$p1 : $p2 : $cl\n"} |
| 40 |
else { print "$p1 : $p2 : $cl\n" unless $p1 =~ /^[\[]/ || $p2 =~ /^[\[]/ ; } |
| 41 |
$p1 = $p2 = $bt = $cl = ""; } |
| 42 |
else {""} |
| 43 |
} |
| 44 |
}); |
| 45 |
|
| 46 |
__END__ |
| 47 |
|
| 48 |
=head1 NAME |
| 49 |
|
| 50 |
thesaurus2biling - converts a ISO-... thesaurus in a bilingual dictionary |
| 51 |
|
| 52 |
=head1 SYNOPSIS |
| 53 |
|
| 54 |
thesaurus2biling [-all] lang1..lang2 thesaurus > bilingDict |
| 55 |
|
| 56 |
=head1 DESCRIPTION |
| 57 |
|
| 58 |
|
| 59 |
By default the terms straring with "[" are skiped. Use "-all" option |
| 60 |
to obtain all the terms. |
| 61 |
|
| 62 |
=head2 Output Format |
| 63 |
|
| 64 |
<term lang1>:<term lang2>:<class> |
| 65 |
<term lang1>:<term lang2>:<class> |
| 66 |
|
| 67 |
=head1 AUTHOR |
| 68 |
|
| 69 |
J.Joao Almeida, [email protected] |
| 70 |
|
| 71 |
=head1 SEE ALSO |
| 72 |
|
| 73 |
perl(1). |
| 74 |
|
| 75 |
=cut |
| 76 |
|