blib/lib/Lingua/Jspell/EAGLES.pm

filter: Statementstmt 9.5% 11 / 115 Branchbran 0.0% 0 / 38 Conditioncond 0.0% 0 / 64 MC/DCmcdc 0.0% 0 / 33 Subroutinesub 8.7% 2 / 23 Podpod n/a totaltotal 4.7% 13 / 273 SCAR 77.3
CC
51
Cov
5%
__ANON__
72.0
__ANON__
72.0
__ANON__
56.0
CRAP 2276.2
« blib/lib/Lingua/Jspell/DictManager.pm ↑ Summary blib/lib/Lingua/Jspell/ConfigData.pm »
1 package Lingua::Jspell::EAGLES;
2  
3 # Mais uma vez, isto tudo é específico do português.
4 # algum código devia passar a ser baseado num YAML qualquer
5 # que defina a estrutura certa.
6 #
7 # para já, não abrir demasiadas frentes.
8  
9 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 our $VERSION = '1.96';
13  
14 # modo: {I}ndicativo, {S}ubjuntivo, i{M}perativo,
15 # i{N}finitivo, {G}erundio, {P}articipio
16 # tempo: {P}resente, {I}mperfeito, {F}uturo,
17 # pas{S}ado, {C}ondicional
18 2 my %temposverbais = (
19 ip => "NE", # infinitivo pessoal ???FIXME(tempo E = pEssoal)
20 inf => "N0", # infinitivo
21 pp => "IS", # pretérito perfeito (simples)
22 ppa => "P0", # particípio passado
23 pc => "SP", # presente do conjuntivo
24 pic => "SI", # pretérito imperfeito do conjuntivo
25 c => "IC", # condicional
26 p => "IP", # presente
27 fc => "SF", # futuro do conjuntivo
28 g => "G0", # gerúndio
29 pmp => "IM", # pretérito mais que perfeito ???FIXME (tempo M = mais que perf.)
30 pi => "II", # pretérito Imperfeito
31 f => "IF", # Futuro
32 i => "M0", # iMperativo
33 );
34  
35 # NUNCA NA VIDA JUNTAR ESTAS DUAS LINHAS
36 # NUMA ÚNICA OU A REGRA DO a_nc DEIXA DE
37 # FUNCIONAR.
38  
39 2 my %rules;
40 %rules = (
41 ## --[ Pronomes - Artigos ]--
42 0 ▶ art => sub { my %fea = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
43 return "D"
44 . (exists($fea{CLA}) && $fea{CLA} eq "indef" ? "I":"A")
45 . "0"
46 . uc($fea{G})
47 . uc($fea{N})
48 0 ▶ . "0";
Branch: 1 branch
BranchTrueFalseTotal
exists $fea{'CLA'} && $fea{'CLA'} eq 'indef' ? : 0 0 0
Condition0%0/3
exists $fea{"CLA"} and $fea{"CLA"} eq "indef"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $fea{"CLA"} and $fea{"CLA"} eq "indef"
exists $fea{"CLA"} $fea{"CLA"} eq "indef"
Truth table0%0/3
A and B
A= exists $fea{"CLA"}B= $fea{"CLA"} eq "indef"
ABresult
0X0
100
111
49 },
50 ## --[ Números Cardinais ]--
51 card => sub {
52 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
53 0 ▶ return "Z0" . uc($fea{G} || "0") . uc($fea{N} || "0")
Condition0%0/4
$fea{'G'} || '0'
l!l
00
$fea{'N'} || '0'
l!l
00
MC/DC0%0/1
$fea{'G'} || '0'
$fea{'G'}
MC/DC0%0/1
$fea{'N'} || '0'
$fea{'N'}
Truth table0%0/2
A
A= $fea{'G'}
Aresult
11
00
Truth table0%0/2
A
A= $fea{'N'}
Aresult
11
00
54 },
55 ## --[ Números Ordinais ]--
56 nord => sub {
57 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
58 0 ▶ return "AO0" . uc($fea{G} || "0") . uc($fea{N} || "0") . "0"
Condition0%0/4
$fea{'G'} || '0'
l!l
00
$fea{'N'} || '0'
l!l
00
MC/DC0%0/1
$fea{'G'} || '0'
$fea{'G'}
MC/DC0%0/1
$fea{'N'} || '0'
$fea{'N'}
Truth table0%0/2
A
A= $fea{'G'}
Aresult
11
00
Truth table0%0/2
A
A= $fea{'N'}
Aresult
11
00
59 },
60 ## --[ Pronomes Pessoais ]--
61 ppes => sub {
62 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=8 SCAR=42.8
63 0 my $tag = "PP";
64
65 # pessoa (1,2,3)
66 0 ▶ $tag .= uc($fea{P} || 0);
Condition0%0/2
$fea{'P'} || 0
l!l
00
MC/DC0%0/1
$fea{'P'} || 0
$fea{'P'}
Truth table0%0/2
A
A= $fea{'P'}
Aresult
11
00
67  
68 # género (M,F,Comum,Neutro)
69 0 ▶ my $G = exists $fea{G} ? uc $fea{G} : "0";
Branch: 1 branch
BranchTrueFalseTotal
exists $fea{'G'} ? : 0 0 0
70 0 ▶ $G = "C" if $G eq "2";
Branch: 1 branch
BranchTrueFalseTotal
if $G eq 2 0 0 0
71 0 ▶ $G = "0" if $G eq "_"; # XXX ????????
Branch: 1 branch
BranchTrueFalseTotal
if $G eq "_" 0 0 0
72 0 $tag .= $G;
73  
74 # Numero (S, P, N --impessoal/invariavel)
75 $tag .= exists $fea{P}
76 0 ▶ ? ($fea{P} =~ /[SP]/i ? uc($fea{P}) : "N")
Branch: 2 branches
BranchTrueFalseTotal
exists $fea{'P'} ? : 0 0 0
$fea{'P'} =~ /[SP]/i ? : 0 0 0
77 : "0";
78 # Caso (nominativo, acusativo, dativo, obliquo)
79 0 ▶ $tag .= exists $fea{C} ? uc($fea{C}) : "0";
Branch: 1 branch
BranchTrueFalseTotal
exists $fea{'C'} ? : 0 0 0
80  
81 # possuidor (Singluar, Plural)
82 # XXX --- temos disto? Não --> so nos ppos
83 0 $tag .= "0"
84
85 },
86 ## --[ Pronomes Possessivos ]--
87 ppos => sub {
88 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=5 SCAR=34.0
89 return "PX"
90 . uc($fea{P} || "0")
91 . uc($fea{G} || "0")
92 . uc($fea{N} || "0")
93 . "0"
94 0 ▶ . uc($fea{NP} || "0")
Condition0%0/8
$fea{'P'} || '0'
l!l
00
$fea{'G'} || '0'
l!l
00
$fea{'N'} || '0'
l!l
00
$fea{'NP'} || '0'
l!l
00
MC/DC0%0/1
$fea{'P'} || '0'
$fea{'P'}
MC/DC0%0/1
$fea{'G'} || '0'
$fea{'G'}
MC/DC0%0/1
$fea{'N'} || '0'
$fea{'N'}
MC/DC0%0/1
$fea{'NP'} || '0'
$fea{'NP'}
Truth table0%0/2
A
A= $fea{'P'}
Aresult
11
00
Truth table0%0/2
A
A= $fea{'G'}
Aresult
11
00
Truth table0%0/2
A
A= $fea{'N'}
Aresult
11
00
Truth table0%0/2
A
A= $fea{'NP'}
Aresult
11
00
95 ;
96
97 # pessoa (1,2,3)
98 # género (M,F,Comum,Neutro)
99 # Numero (S, P, N --impessoal/invariavel)
100 # Caso (nominativo, acusativo, dativo, obliquo)
101 # possuidor (Singluar, Plural)
102 },
103 ## --[ Pronomes Indefinido ]--
104 pind => sub {
105 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
106 my $tag = "PI"
107 . "0"
108 . uc($fea{G} || "0")
109 0 ▶ . uc($fea{N} || "0")
Condition0%0/4
$fea{'G'} || '0'
l!l
00
$fea{'N'} || '0'
l!l
00
MC/DC0%0/1
$fea{'G'} || '0'
$fea{'G'}
MC/DC0%0/1
$fea{'N'} || '0'
$fea{'N'}
Truth table0%0/2
A
A= $fea{'G'}
Aresult
11
00
Truth table0%0/2
A
A= $fea{'N'}
Aresult
11
00
110 . "0"
111 . "0"
112 ;
113 0 $tag =~ s/_/0/g;
114 0 $tag;
115
116 # pessoa (1,2,3)
117 # género (M,F,Comum,Neutro)
118 # Numero (S, P, N --impessoal/invariavel)
119 # Caso (nominativo, acusativo, dativo, obliquo)
120 # possuidor (Singluar, Plural)
121 },
122 ## --[ Pronomes Relativos ]--
123 prel => sub {
124 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=4 SCAR=30.0
125 my $tag = "PR"
126 . "0"
127 . uc($fea{G} || "0")
128 . uc($fea{N} || "0")
129 0 ▶ . uc($fea{C} || "0")
Condition0%0/6
$fea{'G'} || '0'
l!l
00
$fea{'N'} || '0'
l!l
00
$fea{'C'} || '0'
l!l
00
MC/DC0%0/1
$fea{'G'} || '0'
$fea{'G'}
MC/DC0%0/1
$fea{'N'} || '0'
$fea{'N'}
MC/DC0%0/1
$fea{'C'} || '0'
$fea{'C'}
Truth table0%0/2
A
A= $fea{'G'}
Aresult
11
00
Truth table0%0/2
A
A= $fea{'N'}
Aresult
11
00
Truth table0%0/2
A
A= $fea{'C'}
Aresult
11
00
130 . "0"
131 ;
132 0 $tag =~ s/_/0/g;
133 0 $tag;
134 # pessoa (1,2,3)
135 # género (M,F,Comum,Neutro)
136 # Numero (S, P, N --impessoal/invariavel)
137 # Caso (nominativo, acusativo, dativo, obliquo)
138 # possuidor (Singluar, Plural)
139 },
140 ## --[ Pronomes Demonstrativos ]--
141 pdem => sub {
142 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
143 return "PD"
144 . "0"
145 . uc($fea{G} || "0")
146 0 ▶ . uc($fea{N} || "0")
Condition0%0/4
$fea{'G'} || '0'
l!l
00
$fea{'N'} || '0'
l!l
00
MC/DC0%0/1
$fea{'G'} || '0'
$fea{'G'}
MC/DC0%0/1
$fea{'N'} || '0'
$fea{'N'}
Truth table0%0/2
A
A= $fea{'G'}
Aresult
11
00
Truth table0%0/2
A
A= $fea{'N'}
Aresult
11
00
147 . "00";
148
149 # pessoa (1,2,3)
150 # género (M,F,Comum,Neutro)
151 # Numero (S, P, N --impessoal/invariavel)
152 # Caso (nominativo, acusativo, dativo, obliquo)
153 # possuidor (Singluar, Plural)
154 },
155 ## --[ Pronomes interrogativos ]--
156 pint => sub {
157 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
158 0 my $tag = "PT";
159
160 # pessoa (1,2,3)
161 # género (M,F,Comum,Neutro)
162 # Numero (S, P, N --impessoal/invariavel)
163 # Caso (nominativo, acusativo, dativo, obliquo)
164 # possuidor (Singluar, Plural)
165 },
166 ## --[ Verbos ]--
167 v => sub {
168 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=8 SCAR=42.8
169 0 my $tag = "V";
170  
171 # (XXX) tipo (principal, auxiliar, semiauxiliar...)
172 0 $tag .= "0";
173 $tag .= ( $fea{rad} eq "ter" ? "A"
174 0 ▶ : $fea{rad} eq "ser" ? "S"
Branch: 2 branches
BranchTrueFalseTotal
$fea{'rad'} eq 'ter' ? : 0 0 0
$fea{'rad'} eq 'ser' ? : 0 0 0
175 : "M"
176 );
177  
178
179 0 ▶ $tag .= $temposverbais{$fea{T}} || "00";
Condition0%0/2
$temposverbais{$fea{'T'}} || '00'
l!l
00
MC/DC0%0/1
$temposverbais{$fea{'T'}} || '00'
$temposverbais{$fea{'T'}}
Truth table0%0/2
A
A= $temposverbais{$fea{'T'}}
Aresult
11
00
180  
181 # pessoa (1,2,3) -- 1_3 é desdobrado abaixo
182 0 ▶ $tag .= exists($fea{P}) ? $fea{P} : "0";
Branch: 1 branch
BranchTrueFalseTotal
exists $fea{'P'} ? : 0 0 0
183  
184 # numero (S, P)
185 0 ▶ $tag .= exists($fea{N}) ? uc($fea{N}) : "0";
Branch: 1 branch
BranchTrueFalseTotal
exists $fea{'N'} ? : 0 0 0
186  
187 # genero (M,F)
188 0 ▶ $tag .= exists($fea{G}) ? uc($fea{G}) : "0";
Branch: 1 branch
BranchTrueFalseTotal
exists $fea{'G'} ? : 0 0 0
189  
190 # Desdobrar pessoa.
191 0 ▶ if ($tag =~ /1_3/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /1_3/) { } 0 0 0
192 0 my ($one, $three) = ($tag) x 2;
193 0 $one =~ s/1_3/1/;
194 0 $three =~ s/1_3/3/;
195 0 return ($one, $three)
196 } else {
197 0 return $tag;
198 }
199 },
200 ## --[ Preposições ]--
201 0 ▶ prep => sub { "SPS00" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
202 ## --[ Advérbios ]--
203 adv => sub {
204 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
205 0 my $tag = "R";
206 0 ▶ $tag .= exists($fea{SUBCAT}) && $fea{SUBCAT} eq "neg" ? "N" : "G";
Branch: 1 branch
BranchTrueFalseTotal
exists $fea{'SUBCAT'} && $fea{'SUBCAT'} eq 'neg' ? : 0 0 0
Condition0%0/3
exists $fea{"SUBCAT"} and $fea{"SUBCAT"} eq "neg"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $fea{"SUBCAT"} and $fea{"SUBCAT"} eq "neg"
exists $fea{"SUBCAT"} $fea{"SUBCAT"} eq "neg"
Truth table0%0/3
A and B
A= exists $fea{"SUBCAT"}B= $fea{"SUBCAT"} eq "neg"
ABresult
0X0
100
111
207 0 return $tag;
208 },
209 ## --[ Interjeições ]--
210 0 ▶ in => sub { return "I" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
211 ## --[ Conjunções ]--
212 0 ▶ con => sub { return "C0" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
213 ## --[ Contrações ]--
214 0 ▶ punct => sub { return "F" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
215 ## --[ Contrações ]--
216 cp => sub {
217 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
218 0 ▶ return "SPC" . uc($fea{G} || "0") . uc($fea{N} || "0")
Condition0%0/4
$fea{'G'} || '0'
l!l
00
$fea{'N'} || '0'
l!l
00
MC/DC0%0/1
$fea{'G'} || '0'
$fea{'G'}
MC/DC0%0/1
$fea{'N'} || '0'
$fea{'N'}
Truth table0%0/2
A
A= $fea{'G'}
Aresult
11
00
Truth table0%0/2
A
A= $fea{'N'}
Aresult
11
00
219 },
220 ## --[ Nomes Comuns ]--
221 nc => sub {
222 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=5 SCAR=34.0
223 0 my $tag = "NC";
224  
225 0 ▶ my $gen = uc($fea{G} || '0');
Condition0%0/2
$fea{'G'} || '0'
l!l
00
MC/DC0%0/1
$fea{'G'} || '0'
$fea{'G'}
Truth table0%0/2
A
A= $fea{'G'}
Aresult
11
00
226 0 $gen =~ s/[^MF0]/C/i;
227 0 $tag .= $gen;
228  
229 0 ▶ my $num = uc($fea{N} || '0');
Condition0%0/2
$fea{'N'} || '0'
l!l
00
MC/DC0%0/1
$fea{'N'} || '0'
$fea{'N'}
Truth table0%0/2
A
A= $fea{'N'}
Aresult
11
00
230 0 $num =~ s/[^SP0]/N/;
231 0 $tag .= $num;
232  
233 # tipo de nome
234 0 $tag .= "00";
235  
236 0 ▶ my $grad = $fea{GR} || "";
Condition0%0/2
$fea{'GR'} || ''
l!l
00
MC/DC0%0/1
$fea{'GR'} || ''
$fea{'GR'}
Truth table0%0/2
A
A= $fea{'GR'}
Aresult
11
00
237 0 $grad =~ s/dim/D/i;
238 0 $grad =~ s/aum/A/i;
239 0 ▶ $grad = "0" unless $grad =~ /^[DA]$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $grad =~ /^[DA]$/ 0 0 0
240  
241 0 $tag .= $grad;
242  
243 0 return $tag;
244 },
245 ## --[ Nomes Próprios ]--
246 np => sub {
247 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=7 SCAR=40.3
248 0 my $tag = "NP";
249  
250 0 ▶ my $gen = uc($fea{G} || '0');
Condition0%0/2
$fea{'G'} || '0'
l!l
00
MC/DC0%0/1
$fea{'G'} || '0'
$fea{'G'}
Truth table0%0/2
A
A= $fea{'G'}
Aresult
11
00
251 0 $gen =~ s/[^MF0]/C/;
252 0 $tag .= $gen;
253  
254 0 ▶ my $num = uc($fea{N} || '0');
Condition0%0/2
$fea{'N'} || '0'
l!l
00
MC/DC0%0/1
$fea{'N'} || '0'
$fea{'N'}
Truth table0%0/2
A
A= $fea{'N'}
Aresult
11
00
255 0 $num =~ s/[^SP0]/N/;
256 0 $tag .= $num;
257  
258 0 ▶ $tag .= ($fea{SEM} || "") =~ /^p/i ? "SP" : "V0";
Branch: 1 branch
BranchTrueFalseTotal
($fea{'SEM'} || '') =~ /^p/i ? : 0 0 0
Condition0%0/2
$fea{'SEM'} || ''
l!l
00
MC/DC0%0/1
$fea{'SEM'} || ''
$fea{'SEM'}
Truth table0%0/2
A
A= $fea{'SEM'}
Aresult
11
00
259
260 0 ▶ my $grad = $fea{GR} || "";
Condition0%0/2
$fea{'GR'} || ''
l!l
00
MC/DC0%0/1
$fea{'GR'} || ''
$fea{'GR'}
Truth table0%0/2
A
A= $fea{'GR'}
Aresult
11
00
261 0 $grad =~ s/dim/D/i;
262 0 $grad =~ s/aum/A/i;
263 0 ▶ $grad = "0" unless $grad =~ /^[DA]$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $grad =~ /^[DA]$/ 0 0 0
264 0 $tag .= $grad;
265  
266 0 return $tag;
267 },
268 ## --[ Adjetivos ]--
269 adj => sub {
270 0 ▶ my %fea = @_;
Subroutine __ANON__: not called CC=5 SCAR=34.0
271 0 my $tag = "A0";
272  
273 0 ▶ my $grad = $fea{GR} || "";
Condition0%0/2
$fea{'GR'} || ''
l!l
00
MC/DC0%0/1
$fea{'GR'} || ''
$fea{'GR'}
Truth table0%0/2
A
A= $fea{'GR'}
Aresult
11
00
274 0 $grad =~ s/dim/D/i;
275 0 $grad =~ s/aum/A/i;
276 0 $grad =~ s/sup/S/i;
277 0 ▶ $grad = "0" unless $grad =~ /^[DSA]$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $grad =~ /^[DSA]$/ 0 0 0
278 0 $tag .= $grad;
279  
280 0 ▶ my $gen = uc($fea{G} || '0');
Condition0%0/2
$fea{'G'} || '0'
l!l
00
MC/DC0%0/1
$fea{'G'} || '0'
$fea{'G'}
Truth table0%0/2
A
A= $fea{'G'}
Aresult
11
00
281 0 $gen =~ s/[^MF0]/C/;
282 0 $tag .= $gen;
283  
284 0 ▶ my $num = uc($fea{N} || '0');
Condition0%0/2
$fea{'N'} || '0'
l!l
00
MC/DC0%0/1
$fea{'N'} || '0'
$fea{'N'}
Truth table0%0/2
A
A= $fea{'N'}
Aresult
11
00
285 0 $num =~ s/[^SP0]/N/;
286 0 $tag .= $num;
287  
288 0 return $tag . "0";
289 },
290 ## --[ Nomes e Adjetivos ]--
291 a_nc => sub {
292 0 ▶ return ( $rules{nc}->(@_) , $rules{adj}->(@_) );
Subroutine __ANON__: not called CC=1 SCAR=6.9
293 },
294 2 );
295  
296 sub _cat2eagles {
297 0 ▶ my %fea = @_;
Subroutine _cat2eagles: not called CC=2 SCAR=17.9
298  
299 0 ▶ if (exists($rules{$fea{CAT}})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rules{$fea{'CAT'}}) { } 0 0 0
300 0 return $rules{$fea{CAT}}->(%fea);
301 } else {
302 0 return "_UNK"
303 }
304 }
305  
306 2 1;
307  
308 __END__
« blib/lib/Lingua/Jspell/DictManager.pm ↑ Summary blib/lib/Lingua/Jspell/ConfigData.pm »