source:
app/src/dgp/canonize
@
9b57c4d
Last change on this file since 9b57c4d was adb4c8d, checked in by pawelk <pawelk@…>, 17 years ago | |
---|---|
|
|
File size: 622 bytes |
Rev | Line | |
---|---|---|
[0214596] | 1 | #!/usr/bin/perl |
2 | ||
3 | #package: UAM TExt Tools | |
4 | #component: canonize | |
5 | #version: 1.0 | |
6 | #author: Tomasz Obrebski | |
7 | ||
[6b3be72] | 8 | use lib "/usr/local/lib/utt"; |
[adb4c8d] | 9 | use lib "$ENV{'HOME'}/.local/lib/utt"; |
[6b3be72] | 10 | |
[0214596] | 11 | use strict; |
12 | use Getopt::Long; | |
13 | use attr; | |
[6b3be72] | 14 | |
[0214596] | 15 | |
16 | my $help; | |
17 | ||
18 | GetOptions("help|h" => \$help); | |
19 | ||
20 | if($help) | |
21 | { | |
22 | print <<'END' | |
23 | ||
24 | Transforms syntactic categories to their canonical form. | |
25 | ||
26 | Usage: canonize | |
27 | ||
28 | Options: | |
29 | --help -h Help. | |
30 | ||
31 | END | |
32 | ; | |
33 | exit 0; | |
34 | } | |
35 | ||
36 | #$|=1; | |
37 | ||
38 | my %tra; | |
39 | ||
40 | while(<>) | |
41 | { | |
42 | s/$attr::pos_re\/$attr::avlist_re/trans($&)/ge; | |
43 | print; | |
44 | } | |
45 | ||
46 | sub trans | |
47 | { | |
48 | my $cat=shift; | |
49 | exists($tra{$cat}) ? $tra{$cat} : ( $tra{$cat} = attr::canonize $cat ); | |
50 | } |
Note: See TracBrowser
for help on using the repository browser.