#!/usr/bin/perl -s our ($id,$r); $id ||= "__jj1-constituicao"; my @l = (); if ($r) {@l = (direction => "<~") } ## reverse use NAT::Client; use Data::Dumper; $Data::Dumper::Indent=1; $Data::Dumper::Terse=1; my $client = NAT::Client->new( Local => "./$id"); prompt(); while(<>){ chomp; # my $a = $client->ptd( { @l }, $_); my $a = $client->ptd( { }, $_); ppentry("=> ", $a) if ($a->[0]); $a = $client->ptd({ direction => "<~"}, $_); ppentry("<= ", $a) if ($a->[0]); prompt(); } sub prompt{ print "\n> "} sub ppentry{ my $d=shift; my $e=shift; print "$d-------------- $e->[2] ($e->[0])---------\n"; for my $t (sort {$e->[1]{$b} <=> $e->[1]{$a}} keys %{$e->[1]}) { printf("%5.1f ..... %-15s\n", 100*$e->[1]{$t}, $t); } } __END__ =head1 NAME jj-4 - example for (ptd) consult =head1 SYNOPSIS jj-4 jj-4 -r $a = $client->ptd( { options }, $word); print Dumper $a =head1 DESCRIPTION (Previously: jj-1 -> to create the corpus) Print the words and number of occurrences. Example of output: que [ 289, { 'que' => '0.96745', 'cual' => '0.01458' }, 'que' ] =head1 AUTHOR J.Joao Almeida, jj@di.uminho.pt =head1 SEE ALSO perl(1). =cut