line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::EN::Inflexion::Indefinite; |
2
|
24
|
|
|
24
|
|
533
|
use 5.010; use warnings; |
|
24
|
|
|
24
|
|
75
|
|
|
24
|
|
|
|
|
117
|
|
|
24
|
|
|
|
|
41
|
|
|
24
|
|
|
|
|
12851
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# This module implements A/AN inflexion for nouns... |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Special cases of A/AN... |
7
|
|
|
|
|
|
|
my $ORDINAL_AN = qr{\A [aefhilmnorsx] -?th \Z}ix; |
8
|
|
|
|
|
|
|
my $ORDINAL_A = qr{\A [bcdgjkpqtuvwyz] -?th \Z}ix; |
9
|
|
|
|
|
|
|
my $EXPLICIT_AN = qr{\A (?: euler | hour(?!i) | heir | honest | hono )}ix; |
10
|
|
|
|
|
|
|
my $SINGLE_AN = qr{\A [aefhilmnorsx] \Z}ix; |
11
|
|
|
|
|
|
|
my $SINGLE_A = qr{\A [bcdgjkpqtuvwyz] \Z}ix; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# This pattern matches strings of capitals (i.e. abbreviations) that |
14
|
|
|
|
|
|
|
# start with a "vowel-sound" consonant followed by another consonant, |
15
|
|
|
|
|
|
|
# and which are not likely to be real words |
16
|
|
|
|
|
|
|
# (oh, all right then, it's just magic!)... |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $ABBREV_AN = qr{ |
19
|
|
|
|
|
|
|
\A |
20
|
|
|
|
|
|
|
(?! FJO | [HLMNS]Y. | RY[EO] | SQU |
21
|
|
|
|
|
|
|
| ( F[LR]? | [HL] | MN? | N | RH? | S[CHKLMNPTVW]? | X(YL)?) [AEIOU] |
22
|
|
|
|
|
|
|
) |
23
|
|
|
|
|
|
|
[FHLMNRSX][A-Z] |
24
|
|
|
|
|
|
|
}xms; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# This pattern codes the beginnings of all english words begining with a |
27
|
|
|
|
|
|
|
# 'Y' followed by a consonant. Any other Y-consonant prefix therefore |
28
|
|
|
|
|
|
|
# implies an abbreviation... |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $INITIAL_Y_AN = qr{\A y (?: b[lor] | cl[ea] | fere | gg | p[ios] | rou | tt)}xi; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub prepend_indefinite_article { |
33
|
478
|
|
|
478
|
0
|
971
|
my ($word) = @_; |
34
|
478
|
|
|
|
|
859
|
return select_indefinite_article($word) . " $word"; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub select_indefinite_article { |
38
|
478
|
|
|
478
|
0
|
799
|
my ($word) = @_; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Handle ordinal forms... |
41
|
478
|
100
|
|
|
|
2635
|
return "a" if $word =~ $ORDINAL_A; |
42
|
422
|
100
|
|
|
|
1976
|
return "an" if $word =~ $ORDINAL_AN; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Handle special cases... |
45
|
374
|
100
|
|
|
|
1288
|
return "an" if $word =~ $EXPLICIT_AN; |
46
|
356
|
50
|
|
|
|
1023
|
return "an" if $word =~ $SINGLE_AN; |
47
|
356
|
50
|
|
|
|
985
|
return "a" if $word =~ $SINGLE_A; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Handle abbreviations... |
50
|
356
|
100
|
|
|
|
1472
|
return "an" if $word =~ $ABBREV_AN; |
51
|
340
|
100
|
|
|
|
884
|
return "an" if $word =~ /\A [aefhilmnorsx][.-]/xi; |
52
|
308
|
100
|
|
|
|
761
|
return "a" if $word =~ /\A [a-z][.-]/xi; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Handle consonants |
55
|
|
|
|
|
|
|
|
56
|
286
|
100
|
|
|
|
1278
|
return "a" if $word =~ /\A [^aeiouy] /xi; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Handle special vowel-forms |
59
|
|
|
|
|
|
|
|
60
|
180
|
100
|
|
|
|
448
|
return "a" if $word =~ /\A e [uw] /xi; |
61
|
168
|
100
|
|
|
|
338
|
return "a" if $word =~ /\A onc?e \b /xi; |
62
|
164
|
100
|
|
|
|
498
|
return "a" if $word =~ /\A uni (?: [^nmd] | mo) /xi; |
63
|
132
|
100
|
|
|
|
255
|
return "an" if $word =~ /\A ut[th] /xi; |
64
|
130
|
100
|
|
|
|
393
|
return "a" if $word =~ /\A u [bcfhjkqrst] [aeiou] /xi; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Handle special capitals |
67
|
|
|
|
|
|
|
|
68
|
102
|
100
|
|
|
|
198
|
return "a" if $word =~ /\A U [NK] [AIEO]? /x; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Handle vowels |
71
|
|
|
|
|
|
|
|
72
|
98
|
100
|
|
|
|
595
|
return "an" if $word =~ /\A [aeiou]/xi; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Handle Y... (before certain consonants implies (unnaturalized) "I.." sound) |
75
|
20
|
100
|
|
|
|
126
|
return "an" if $word =~ $INITIAL_Y_AN; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Otherwise, guess "A" |
78
|
10
|
|
|
|
|
63
|
return "a"; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
83
|
|
|
|
|
|
|
__END__ |