#!/usr/bin/perl #package: UAM TExt Tools #component: canonize #version: 1.0 #author: Tomasz Obrebski use strict; use Getopt::Long; use attr; #use File::HomeDir; #use lib "$ENV{HOME}/.utt/lib/perl"; my $help; GetOptions("help|h" => \$help); if($help) { print <<'END' Transforms syntactic categories to their canonical form. Usage: canonize Options: --help -h Help. END ; exit 0; } #$|=1; my %tra; while(<>) { s/$attr::pos_re\/$attr::avlist_re/trans($&)/ge; print; } sub trans { my $cat=shift; exists($tra{$cat}) ? $tra{$cat} : ( $tra{$cat} = attr::canonize $cat ); }