Debian Codegraph @

examples/thesaurusSC

raw
1 #!/usr/bin/perl -w -s
2
3 our ($ori,$ablt,$rblt,$protcom) ;
4
5 my ($bl,$langpat,%l);
6 $bl = $ablt if (defined $ablt) && ($ablt =~ /[A-Za-z]+/);
7 $bl = $rblt if (defined $rblt) && ($rblt =~ /[A-Za-z]+/);
8
9 $/='';
10
11 my $s;
12 while(<>){
13 chomp;
14 if(/^\%/){
15 if (/\%baselang(?:uage)?\s+(\S+)/) { $bl ||= $1; }
16 while( m/\%lang(?:uage)?\s+(\S+.*)/g) {
17 my $ls = $1;
18 for ($ls =~ m/(\S+)/g){ $l{$_} = 1};
19 $langpat=join('|',keys %l)}
20 }
21 elsif(/^[#]/) { }
22 elsif(/^(.*)/) {
23 if($protcom){
24 while( s/^(.*?)\s*,\s*/$1 _and / ){}
25 if($langpat){while( s/(\n(?:$langpat))(.*?)\s*,\s*/$1$2 _and / ){} }
26 }
27 $_ .= "\nFROM $ori" if $ori;
28 $_ = "$bl $_" if $ablt;
29 $_ =~ s/^$bl\s+//i if $rblt;
30 }
31 print "$_\n\n";
32 }
33
34 __END__
35
36 =head1 NAME
37
38 thesaurusSC - Make thesaurus changes (simple changes)
39
40 =head1 SYNOPSIS
41
42 thesaurusSC -ori=Natura file.the (adds "FROM Natura" to each entry)
43 thesaurusSC -ablt[=PT] file.the (adds "baselang tag" to each entry)
44 thesaurusSC -rblt[=PT] file.the (removes "baselang tag" from each entry)
45 thesaurusSC -protcom file.the (protect commas "," --> "_and ")
46
47 =head1 DESCRIPTION
48
49 Make simple changes in Thesaurus files.
50
51 1 add origin
52 2 add baselang tag
53 3 removes baselang tag
54 4 protcom protect commas in term and language
55 5 cat (not yet implemented)
56
57 =head1 AUTHOR
58
59 J.Joao Almeida, [email protected]
60
61 =head1 SEE ALSO
62
63 perl(1).
64
65 =cut