Debian Codegraph @

examples/biling2thesaurus

raw
1 #!/usr/bin/perl -s
2
3 our ($bl,$l1,$l2,$sep,$rel,$norel);
4 $sep ||= ":";
5 $rel ||= "BT" unless $norel;
6 die("usage: $0 [-l1=EN] [-l2=PT] [-rel=IOF] [-sep=:] [-norel] file\n")
7 unless $l1 || $l2;
8 # $l1 = 1 unless $l2;
9
10 print "%baselang $bl\n%lang $bl $l1 $l2\n\n" if $bl;
11
12 while(<>){
13 if(/^[%]enc(?:oding)?\s+(\S+)/){
14 print $_;
15 }
16 elsif(/(.+)$sep(.+)$sep(.+)/){
17 if($l1){ print "$2\n$l1 $1\n", ($norel ? "": "$rel $3\n" ), "\n" ; }
18 else { print "$1\n$l2 $2\n", ($norel ? "": "$rel $3\n" ), "\n" ; }
19 }
20 elsif(/(.+)$sep(.+)/){
21 if($l1){ print "$2\n$l1 $1\n\n" ; }
22 else { print "$1\n$l2 $2\n\n" ; }
23 }
24 elsif(/^\s*$/){ print "\n";}
25 }
26
27 __END__
28
29 =head1 NAME
30
31 biling2thesaurus - converts a ":"-separated bilingual dictionary to ISO thesaurus
32
33 =head1 SYNOPSIS
34
35 biling2thesaurus [-l1=EN|-l2=FR] bilingDict > thesaurus
36
37 =head1 DESCRIPTION
38
39 Converts a Bilingue dictionary into a ISO-thesaurus.
40
41 Input format: lines containing
42
43 term1 : term2 : class
44
45 or
46
47 term1: term2
48
49
50
51 =head2 Input Format
52
53 <term1 lang1>:<term1 lang2>:<class>
54 <term2 lang1>:<term2 lang2>:<class>
55
56 Input files may have a encoding declaration. Example:
57
58 %encoding UTF-8
59
60 =head2 Output Format
61
62 <term1 lang1>
63 LANG2 <term1 lang2>
64 BT <class>
65
66 <term2 lang1>
67 LANG2 <term2 lang2>
68 BT <class>
69
70 =head1 Options
71
72 -l1=FR
73 baselang is lang2;
74 lang1 is french
75
76 -l2=FR
77 baselang is lang1;
78 lang2 is french
79
80 -rel=IOF
81 Relation tag is IOF (default BT)
82
83 -norel
84 Ignore classes in the inputfile (default: show relations)
85
86 -sep="::"
87 field separator is "::" (default ":")
88
89 -bl=PT
90 baselang is PT (makes a %baselang PT in output file)
91
92 =head1 AUTHOR
93
94 J.Joao Almeida, [email protected]
95
96 =head1 SEE ALSO
97
98 perl(1).
99
100 =cut
101