#!/usr/bin/perl -w use strict; use porter; while (<>) { chomp; if (/^[\s]*$/) { print "\n"; next; } my ($class, @tagged) = split /[\s]+/; my @w = (); my @t = (); my @typ = (); for (my $i=0; $i<@tagged; $i++) { $tagged[$i] =~ m/^(.+)_([^_]+)$/; $w[$i] = $1; $t[$i] = $2; my $type = $w[$i]; $type =~ s/NUMBER/0/g; $type =~ s/0+/0/g; $type =~ s/[A-Z]+/A/g; $type =~ s/[a-z]+/a/g; $type =~ s/[^A-Za-z0\.]/S/g; while (length($type) >= 4) { if (substr($type,length($type)-2,2) eq substr($type,length($type)-4,2)) { $type =~ s/..$//; } else { last; } } $typ[$i] = $type; } # print 'Len=' . scalar @w; # for (my $i=1; $i<=10; $i++) { # if (@w <= $i) { print ' LenLE' . $i; } # else { print ' LenGT' . $i; } # } for (my $i=0; $i<@w; $i++) { print ' W=' . $w[$i]; print ' T=' . $t[$i]; print ' Typ=' . $typ[$i]; print ' S=' . stem(lc($w[$i])); print ' Suf1=' . substr(lc($w[$i]), length($w[$i])-1, 1); print ' Suf2=' . substr(lc($w[$i]), length($w[$i])-2, 2); print ' Suf3=' . substr(lc($w[$i]), length($w[$i])-3, 3); print ' Pre1=' . substr(lc($w[$i]), 0, 1); print ' Pre2=' . substr(lc($w[$i]), 0, 2); print ' Pre3=' . substr(lc($w[$i]), 0, 3); print ' T1=' . substr($t[$i], 0, 1); print ' T2=' . substr($t[$i], 0, 2); print ' T3=' . substr($t[$i], 0, 3); } # my $preW = ''; my $preT = $preW; my $preTyp = $preW; # for (my $i=0; $i<@w; $i++) { # print ' BgW=' . $preW . '___' . lc($w[$i]); # print ' BgT=' . $preT . '___' . $t[$i]; # print ' BgTyp=' . $preTyp . '___' . $typ[$i]; # $preW = lc($w[$i]); # $preT = $t[$i]; # $preTyp = $typ[$i]; # } # print ' BgW=' . $preW . '___'; # print ' BgT=' . $preT . '___'; # print ' BgTyp=' . $preTyp . '___'; # print ' WholeW='; # for (my $i=0; $i<@w; $i++) { # if ($i > 0) { print '___'; } # print $w[$i]; # } # print ' WholeT='; # for (my $i=0; $i<@t; $i++) { # if ($i > 0) { print '___'; } # print $t[$i]; # } # print ' WholeType='; # for (my $i=0; $i<@typ; $i++) { # if ($i > 0) { print '___'; } # print $typ[$i]; # } # if (($class ne 'ADJP') && ($class ne 'ADVP') && ($class ne 'NP') && ($class ne 'O') && ($class ne 'PP') && #($class ne 'PRT') && ($class ne 'SBAR') && ($class ne 'VP')) { $class = 'O'; } print " " . $class . "\n"; }