#!/usr/bin/perl -s use strict; use warnings; use Data::Dumper; use NAT::Client; our ($inv); my $dir = shift; my $crp = NAT::Client->new( Local => $dir ); if ($inv) { $crp->iterate( {Language => 'target'}, \&process_term ); } else { $crp->iterate( \&process_term ); } # estou 'a procura de: # A -- 90 --> B # C -- 90 --> B # B -- 40 --> A # B -- 40 --> C sub process_term { my %param = @_; # word, count, trans my @words = sort { $param{trans}{$b} <=> $param{trans}{$a} } grep { $param{trans}{$_} >= 0.2 } keys %{$param{trans}}; if (@words >= 2) { # && abs($param{trans}{$words[0]} - $param{trans}{$words[1]}) <= 0.2) { my ($ptd1,$ptd2); if ($inv) { $ptd1 = $crp->ptd( { direction => '~>' }, $words[0]); $ptd2 = $crp->ptd( { direction => '~>' }, $words[1]); } else { $ptd1 = $crp->ptd( { direction => '<~' }, $words[0]); $ptd2 = $crp->ptd( { direction => '<~' }, $words[1]); } if (exists($ptd1->[1]{$param{word}}) && $ptd1->[1]{$param{word}} >= 0.7 && exists($ptd2->[1]{$param{word}}) && $ptd2->[1]{$param{word}} >= 0.7) { print "Candidato: $param{word} == $words[0] $words[1]\n" } } }