File Coverage

blib/lib/Lingua/FuzzyTrans/PT2GL.pm
Criterion Covered Total %
statement 139 139 100.0
branch n/a
condition n/a
subroutine 45 45 100.0
pod 1 1 100.0
total 185 185 100.0


line stmt bran cond sub pod time code
1 1     1   48606 use utf8;
  1         2  
  1         6  
2 1     1   25 use strict;
  1         2  
  1         15  
3 1     1   3 use warnings;
  1         2  
  1         1652  
4             package Lingua::FuzzyTrans::PT2GL;
5             # ABSTRACT: Translates Portuguese words to Galician using fuzzy replacements
6             $Lingua::FuzzyTrans::PT2GL::VERSION = '0.001';
7             sub translate {
8 1     1 1 80 my ($pt) = @_;
9              
10 1         9 my @subs = qw'ID
11             A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
12             AA AB AC AD AE AF AG AH AI AJ AK AL AM AN';
13              
14              
15 1         2 my $tmp;
16             my $subs = {
17       1     ID => sub { },
18 1     1   7 A => sub { s/ss/s/gi for @$_ },
19 1     1   4 B => sub { s/j/x/gi for @$_},
20             C => sub {
21 1     1   3 my $one = [@$_];
22 1         7 my $two = [@$_];
23              
24 1         7 s/uição$/ución/i for @$one;
25 1         7 s/ção$/ción/i for @$one;
26              
27 1         6 s/ção$/zón/i for @$two;
28              
29 1         1 my %x;
30 1         5 $x{$_}++ for (@$one, @$two);
31 1         7 $_ = [ keys %x ]
32             },
33 1     1   4 D => sub { s/ç/z/gi for @$_},
34 1     1   4 E => sub { s/nh/ñ/gi for @$_ },
35 1     1   5 F => sub { s/dizer$/dicir/i for @$_ },
36 1     1   6 G => sub { s/z(?=[eiéíêî])/c/gi for @$_},
37 1     1   4 H => sub { s/lh/ll/gi for @$_},
38 1     1   4 I => sub { s/vr/br/gi for @$_},
39 1     1   5 J => sub { s/agem$/axe/i for @$_},
40 1     1   7 K => sub { s/g(?=[eiéíêî])/x/ig for @$_},
41             L => sub {
42 1     1   3 my $one = [@$_];
43 1         2 my $two = [@$_];
44              
45 1         5 s/ável$/able/i for @$one;
46 1         4 s/ável$/ábel/i for @$two;
47              
48 1         3 my %x;
49 1         6 $x{$_}++ for (@$one, @$two);
50 1         7 $_ = [ keys %x ]
51             },
52             M => sub {
53 1     1   2 my $one = [@$_];
54 1         3 my $two = [@$_];
55              
56 1         17 s/ível$/ible/i for @$one;
57 1         5 s/ível$/íbel/i for @$two;
58              
59 1         2 my %x;
60 1         5 $x{$_}++ for (@$one, @$two);
61 1         4 $_ = [ keys %x ]
62             },
63             N => sub {
64 1     1   3 my $one = [@$_];
65 1         2 my $two = [@$_];
66              
67 1         5 s/velmente$/belmente/i for @$one;
68 1         4 s/velmente$/blemente/i for @$two;
69              
70 1         2 my %x;
71 1         4 $x{$_}++ for (@$one, @$two);
72 1         4 $_ = [ keys %x ]
73             },
74 1     1   5 O => sub { s/eio$/eo/i for @$_},
75 1     1   5 P => sub { s/ância$/ancia/i for @$_},
76 1     1   4 Q => sub { s/ência$/encia/i for @$_},
77             R => sub {
78 1     1   2 my $one = [@$_];
79 1         3 my $two = [@$_];
80              
81 1         4 s/aria$/ería/i for @$one;
82 1         4 s/aria$/aría/i for @$two;
83              
84 1         1 my %x;
85 1         5 $x{$_}++ for (@$one, @$two);
86 1         4 $_ = [ keys %x ]
87             },
88 1     1   4 S => sub { s/ário$/ario/i for @$_},
89 1     1   5 T => sub { s/óri([oa])$/ori$1/i for @$_},
90             U => sub {
91 1     1   3 my $one = [@$_];
92 1         2 my $two = [@$_];
93              
94 1         5 s/são$/sión/i for @$one;
95 1         4 s/são$/són/i for @$two;
96              
97 1         2 my %x;
98 1         7 $x{$_}++ for (@$one, @$two);
99 1         6 $_ = [ keys %x ]
100             },
101             V => sub {
102 1     1   3 my $one = [@$_];
103 1         3 my $two = [@$_];
104              
105 1         4 s/rão$/rón/i for @$one;
106 1         4 s/rão$/rán/i for @$two;
107              
108 1         2 my %x;
109 1         5 $x{$_}++ for (@$one, @$two);
110 1         3 $_ = [ keys %x ]
111             },
112             W => sub {
113 1     1   3 my $one = [@$_];
114 1         2 my $two = [@$_];
115              
116 1         6 s/mão$/món/i for @$one;
117 1         4 s/mão$/mán/i for @$two;
118              
119 1         2 my %x;
120 1         4 $x{$_}++ for (@$one, @$two);
121 1         3 $_ = [ keys %x ]
122             },
123             X => sub {
124 1     1   3 my $one = [@$_];
125 1         2 my $two = [@$_];
126              
127 1         6 s/ião$/ión/i for @$one;
128 1         4 s/ião$/ián/i for @$two;
129              
130 1         2 my %x;
131 1         4 $x{$_}++ for (@$one, @$two);
132 1         4 $_ = [ keys %x ]
133             },
134 1     1   5 Y => sub { s/ício$/icio/i for @$_ },
135 1     1   8 Z => sub { s/óide$/oide/i for @$_ },
136 1     1   5 AA => sub { s/ídio$/idio/i for @$_ },
137 1     1   4 AB => sub { s/ânico$/ánico/i for @$_ },
138 1     1   4 AC => sub { s/édia$/edia/i for @$_ },
139 1     1   5 AD => sub { s/(.)cimento$/$1cemento/i for @$_ },
140 1     1   4 AE => sub { s/m$/n/i for @$_ },
141 1     1   4 AF => sub { s/crever$/cribir/i for @$_ },
142             AG => sub {
143 1     1   4 my $one = [@$_];
144 1         2 my $two = [@$_];
145              
146 1         4 s/u$/o/i for @$two;
147              
148 1         2 my %x;
149 1         5 $x{$_}++ for (@$one, @$two);
150 1         5 $_ = [ keys %x ]
151             },
152 1     1   6 AH => sub { s/var$/bar/i for @$_ },
153             AI => sub {
154 1     1   2 my $one = [@$_];
155 1         2 my $two = [@$_];
156              
157 1         4 s/^im/inm/i for @$two;
158              
159 1         2 my %x;
160 1         4 $x{$_}++ for (@$one, @$two);
161 1         4 $_ = [ keys %x ]
162             },
163             AJ => sub {
164             #s/qua/cua/i for @$_;
165 1     1   2 my $one = [@$_];
166 1         4 my $two = [@$_];
167 1         7 s/^qua/cua/i for @$one;
168 1         4 s/^qua/ca/i for @$two;
169              
170 1         2 my %x;
171 1         4 $x{$_}++ for (@$one, @$two);
172 1         4 $_ = [ keys %x ]
173             },
174 1     1   4 AK => sub { s/qua/cua/i for @$_ },
175             AL => sub { #s/xão$/xión/i for @$_
176 1     1   2 my $one = [@$_];
177 1         3 my $two = [@$_];
178              
179 1         5 s/xão$/xón/i for @$one;
180 1         4 s/xão$/xión/i for @$two;
181              
182 1         3 my %x;
183 1         4 $x{$_}++ for (@$one, @$two);
184 1         4 $_ = [ keys %x ]
185             },
186             AM => sub {
187 1     1   2 my $one = [@$_];
188 1         2 my $two = [@$_];
189              
190 1         4 s/rv/rb/i for @$two;
191              
192 1         2 my %x;
193 1         4 $x{$_}++ for (@$one, @$two);
194 1         4 $_ = [ keys %x ]
195             },
196 1     1   5 AN => sub { s/iver$/ivir/i for @$_ },
197 1         88 };
198              
199 1         4 local $_ = [$pt];
200 1         3 for my $s (@subs) {
201 41         78 $subs->{$s}->();
202             }
203 1         43 return @$_;
204             }
205              
206              
207             1;
208              
209             __END__