use strict; ##### Ładowanie modułów ############################################# use Aligner; use Features::Levenshtein; use Features::Distance; use Features::Cooccurence; use Adapters::LightTMX; use Algorithms::CompetitiveLinking; ##### Inicjalizacja funkcji cech #################################### my $adapter = new Adapters::LightTMX($ARGV[0]); my $f_levenshtein = new Features::Levenshtein($adapter); my $f_distance = new Features::Distance(); my $f_cooccurence = new Features::Cooccurence($adapter); my @features = ($f_levenshtein, $f_distance, $f_cooccurence); my @weights = (-1.0, -0.5, 0.005); ###### Uruchomienie algorytmu ####################################### my $algorithm = new Algorithms::CompetitiveLinking(); my $aligner = new Aligner($algorithm, $adapter, \@features, \@weights); my $results = $aligner->Run(); ###### Opcjonalne wyświetlenie ###################################### binmode(STDOUT, ":utf8"); $adapter->Reset(); while($adapter->HasNext()) { if ($adapter->{tu_no} > 0) { print "\n"; print "\t".stripPunctuation($adapter->CurrentSource())."", "\n"; print "\t".stripPunctuation($adapter->CurrentTarget())."", "\n"; print "\t"; PrintAlign($results->[$adapter->LineNo()]); print "\n"; print "\n"; print "\n"; } } sub PrintAlign { my $aligned = shift; foreach my $point (@$aligned) { print "$point->[0]-$point->[1] " } } sub stripPunctuation { my $string = shift; $string =~ s/[\.\,\:\;]//g; return $string; }