/usr/bin/thesaurus2any is in libbiblio-thesaurus-perl 0.43-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | #!/usr/bin/perl -s
eval 'exec /usr/bin/perl -s -S $0 ${1+"$@"}'
if 0; # not running under some shell
=head1 NAME
thesaurus2any - translate thesaurus like notation to xml catalogue format
=head1 SYNOPSYS
thesaurus2any -cat file > file.xml
thesaurus2any -thes file > file.the
thesaurus2any -tex file > file.tex
=head1 DESCRIPTION
translates a thesaurus file into XML catalogue format, or thesaurus format
after completion, or to latex format.
=head2 OPTIONS
-cat XML catalogue format
-thes thesaurus format
-tex LaTeX format
-multi
=cut
# use lib qw(/home/jj/lib/perl5/);
use Biblio::Thesaurus;
use vars qw($thes $cat $tex $multi);
if ($multi) {
$the = thesaurusMultiLoad(@ARGV);
} else {
my $thesaurus = shift || die ("use: thesaurus2any filename\n");
$the = thesaurusLoadM($thesaurus);
}
#$the->addInverse('RT' , "RT");
#$the->addInverse('POF' => "HAS");
#$the->addInverse('about' => "citedIn");
#$the->addInverse('needs' => "usedIn");
#$the->addInverse('INST' => "IOF");
#$the->addInverse('makes' => 'by');
sub t2cat{
my @rel= qw( about IOF needs usedin POF NT BT RT INST HAS makes by );
my $corres={
about => [ "rel type='about'","/rel"],
POF => [ "rel type='POF'","/rel"],
makes => [ "rel type='RT'","/rel"],
by => [ "rel type='BT'","/rel"],
SN => [ "description","/description"],
};
for (@rel){$corres->{$_}=["rel type='$_'","/rel"];}
$mydetails = {
'-eachTerm' =>
sub{"<doc>\n <title>$term</title>\n$_" .
($nott? "": " <rel type='IOF'>termo thesaurus</rel>\n").
($nott? "": " <rel type='self'>$_c</rel>\n") .
"</doc>\n\n"},
'-end' => sub{"<catalogo>\n\n$_</catalogo>\n"} ,
};
print "<?xml version='1.0' encoding='ISO-8859-1'?>\n",
$the->toXml($corres,$mydetails);
}
$names = {
# 'NT' => "termo específico",
# 'BT' => "termo genérico",
# 'RT' => "termo associado",
# 'POF' => "parte de",
# 'HAS' => "partes",
# 'about' => "acerca de",
# 'needs' => "necessita de",
# 'usedin' => "usado em",
# 'IOF' => "instância de",
# 'INST' => "instâncias",
# 'makes' => 'obras',
# 'by' => 'autor',
# 'USE' => "ver",
# 'USES' => "sinónimo",
# 'SN' => "Descrição",
};
$auxfile="/tmp/$$.out";
sub t2the{
$the->save($auxfile) ;
print `cat $auxfile` ;
unlink($auxfile);
}
sub t2tex{
print $the->toTex(
{map {$_ => ["\\\\\\emph{$names->{$_}} -- ",""]} keys %$names },
# { -order => [qw{SN NT BT RT IOF HAS}] }
) ;
}
if ($tex){t2tex();}
elsif($cat){t2cat();}
else {t2the();}
|