#!/usr/bin/perl -ws use jspell; use Lingua::PT::PLN; use Data::Dumper; use locale; use strict; our $sep; my $pt_dict = jspell::new("port"); my $en_dict = jspell::new("eng"); print Dumper($pt_dict); my %pnlist=(); my %pnlistD=(); my $file = shift; my %tab=(); sub initTab{ my @pcolectiva =qw{ Direcção Administração Comissão }; my @metaInst = qw{ Instituto Fundação Instituto Universidade Faculdade Escola Departamento Conservatório Academia Sindicato Associação Federação Teatro Grupo Ministério Conselho Câmara Fundo Secretaria Assembleia Centro }; my @pessoa = qw{ Ministro Engenheiro Doutor Presidente Professor Dr. Director Secretário Padre Frei Papa Cónego Arcebispo Bispo Cardeal General Almirante Comandante Capitão Brigadeiro Tenente Alferes Marquês Conde Dom D. Visconde Conselheiro }; my @metaLug = qw{ Lugar Largo Praça Praceta Bairro Rua R. Avenida Av. Travessa Beco Urbanização Quinta Viela Estrada Calçada Rotunda Jardim }; my @monumento = qw{Convento Mosteiro Igreja Palácio Torre Museu Sé Fonte }; @tab{@metaInst} = ("instituição") x @metaInst; @tab{@pcolectiva} = ("pessoa colectiva") x @pcolectiva; @tab{@pessoa} = ("pessoa") x @pessoa; @tab{@metaLug} = ("Lugar") x @metaLug; @tab{@monumento} = ("monumento") x @monumento; } my $procPn= sub{my $a=shift; print STDERR "debud pn1($a)\n"; if($a =~ /(\w+)/){ my $f=$1; my @a=$pt_dict->fea($f); my %b = onethat({CAT => "np"}, @a); if(%b){if (defined $b{SEM}){"$a"} else {print STDERR "?? $a -- no SEM\n"; "$a"}} elsif(defined $tab{$f}){"$a"} else { @a = $en_dict->fea($f); %b = onethat({CAT => "np"}, @a); if(%b){if (defined $b{SEM}){"$a"} else {print STDERR "?? $a -- english but no SEM\n"; "$a"}} else { print STDERR "$a\n....",lookAtTheSecond(n($a)),"\n" ; "$a

"}}} else {"$a

"} }; my $procPn2= sub{my $a=shift; print STDERR "debud pn2($a)\n"; if($a =~ /(\w+)/){ my @a=$pt_dict->fea($1); my %b = onethat({CAT => "np"}, @a); if(%b || scalar @a == 0){&{$procPn}($a)} else{ undef ;}} else {"$a

"} }; sub lookAtTheSecond{ my $p=shift; my ($w1,$sep,$w2,$r); if($p =~ /(\w+)(\s(?:d[eao]s?\s+)?)(\w+)(.*)/){ ($w1,$sep,$w2,$r)=($1,$2,$3,$4); my @f=$pt_dict->fea($w2); my %b = onethat({CAT => "np"}, @f); if(%b and defined $b{SEM}){"$p"} } else {""} } initTab(); forPN({in=>$file, sep=>$sep||'>', out=>"___", t=>"double"}, $procPn,$procPn2); sub n { my $a=shift; $a =~s/\s+/ /g; $a; } __END__ =head1 NAME tagPnWithJspell - a naif REM tagger using jspell =head1 SYNOPSIS tagPnWithJspell example =head1 DESCRIPTION C uses Lingua::PT::PLN to apply a tag function to all Proper names. The tag function uses a Jspell with PT and EN dictionaries and also a table (inluded in C) to try to guess the type of Proper name, and tags it =head1 AUTHOR J.Joao Almeida, jj@di.uminho.pt =head1 SEE ALSO perl(1). =cut