/usr/bin/tax2thesaurus 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 110 111 112 113 114 115 116 117 | #!/usr/bin/perl -s
eval 'exec /usr/bin/perl -s -S $0 ${1+"$@"}'
if 0; # not running under some shell
use strict;
my @tab=(-1);
my @ant=("_top");
my $ind;
my $inda=0;
binmode(STDOUT,":utf8");
@ARGV = ("-") unless @ARGV;
for my $file (@ARGV){
open(F,$file) or die("cant open $file\n");
print "%enc utf8\n\n";
while(<F>){ chomp;
if(/%enc(oding)?\s+(latin1)/){next}
if(/%enc(oding)?\s+(utf8)/i) {binmode(F,":utf8");next}
my $termo;
next unless /\w/;
if(/^([ .-]*)(\S.*)/){
$termo = $2;
$ind = length($1);
## print STDERR "Deb: $_($termo/$ind)\n";
if ($ind <= $inda) {
while(@tab and $ind <= $tab[-1]){ pop(@tab); pop(@ant);}
}
push (@tab,$ind);
push (@ant,$termo);
print "\n$termo\nBT ",$ant[-2] ||"?","\n#lev ", @ant -1,"\n";
$inda = $ind;
}
}
close F;
}
__END__
=head1 NAME
tax2thesaurus - indented taxonomy to thesaurus
=head1 SYNOPSIS
tax2thesaurus file.tax > file.the
=head1 DESCRIPTION
A top term C<_top> is added to the taxonomy.
=head2 example of the taxonomy format
science
physics
dynamics
math
algebra
trignometry
literature
=head2 Correspondent output
science
BT _top
#lev 1
physics
BT science
#lev 2
dynamics
BT physics
#lev 3
math
BT science
#lev 2
algebra
BT math
#lev 3
trignometry
BT math
#lev 3
literature
BT _top
#lev 1
=head1 AUTHOR
J.Joao Almeida, jj@di.uminho.pt
=head1 SEE ALSO
perl(1).
=cut
__END__
Geografia Política
América
América Central
Belize
Costa Rica
El Salvador
Guatemala
Honduras
Nicarágua
Panamá
América Do Norte
Canadá
Alberta
|