| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
{ |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::Google::Spelling - simple OOP-ish interface to the Google SOAP API for spelling suggestions |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Net::Google::Spelling; |
|
10
|
|
|
|
|
|
|
my $spelling = Net::Google::Spelling(\%args); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$spelling->phrase("muntreal qweebec"); |
|
13
|
|
|
|
|
|
|
print $spelling->suggest()."\n"; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Provides a simple OOP-ish interface to the Google SOAP API for |
|
18
|
|
|
|
|
|
|
spelling suggestions. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This package is used by I. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
48
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package Net::Google::Spelling; |
|
27
|
1
|
|
|
1
|
|
5
|
use base qw (Net::Google::tool); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
81
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
479
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$Net::Google::Spelling::VERSION = '1.0'; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 PACKAGE METHODS |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 $pkg = __PACKAGE__->new(\%args) |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Valid arguments are : |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=over 4 |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item * |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
B |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
I.A Google API key. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
If none is provided then the key passed to the parent I |
|
50
|
|
|
|
|
|
|
object will be used. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item * |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
B |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
I or I. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
B |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
I. A URL for proxy-ing HTTP requests. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item * |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
B |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Valid options are: |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=over 4 |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
I |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
If true prints debugging information returned by SOAP::Lite |
|
77
|
|
|
|
|
|
|
to STDERR |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item * |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
I. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Your own subroutine for munging the debugging information |
|
84
|
|
|
|
|
|
|
returned by SOAP::Lite. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=back |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
The object constructor in Net::Google 0.53, and earlier, expected |
|
91
|
|
|
|
|
|
|
a I object as its first argument followed by |
|
92
|
|
|
|
|
|
|
a hash reference of argument. Versions 0.6 and higher are backwards |
|
93
|
|
|
|
|
|
|
compatible. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Returns an object. Woot! |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub new { |
|
100
|
1
|
|
|
1
|
1
|
3
|
my $pkg = shift; |
|
101
|
|
|
|
|
|
|
|
|
102
|
1
|
|
|
|
|
1
|
my $self = {}; |
|
103
|
1
|
|
|
|
|
3
|
bless $self,$pkg; |
|
104
|
|
|
|
|
|
|
|
|
105
|
1
|
0
|
|
|
|
21
|
if (! $self->init(@_)) { |
|
106
|
0
|
|
|
|
|
0
|
return undef; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
0
|
return $self; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub init { |
|
113
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
|
114
|
|
|
|
|
|
|
|
|
115
|
1
|
|
0
|
|
|
10
|
my $args = $self->SUPER::init("spelling",@_) |
|
116
|
|
|
|
|
|
|
|| return 0; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
0
|
|
|
|
|
if ($args->{'phrase'}) { |
|
121
|
0
|
0
|
|
|
|
|
defined($self->phrase( (ref($args->{'phrase'}) eq "ARRAY") ? @{$args->{'phrase'}} : $args->{'phrase'} )) || return 0; |
|
|
0
|
0
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
return 1; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 $obj->key($string) |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Get/set the Google API key for this object. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# Defined in Net::Google::tool |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 $obj->http_proxy($url) |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Get/set the HTTP proxy for this object. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Returns a string. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# Defined in Net::Google::tool |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 $obj->phrase(@words) |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Add one or more words to the phrase you want to spell-check. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
If the first item in I<@words> is empty, then any existing I |
|
154
|
|
|
|
|
|
|
data will be removed before the new data is added. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Returns a string. Returns undef if there was an error. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub phrase { |
|
161
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
162
|
0
|
|
|
|
|
|
my @words = @_; |
|
163
|
|
|
|
|
|
|
|
|
164
|
0
|
0
|
0
|
|
|
|
if ((scalar(@words) > 1) && ($words[0] == "")) { |
|
165
|
0
|
|
|
|
|
|
$self->{'_phrase'} = []; |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
0
|
0
|
|
|
|
|
if (@words) { |
|
169
|
0
|
|
|
|
|
|
push @{$self->{'_phrase'}} , @words; |
|
|
0
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
return join("",@{$self->{'_phrase'}}); |
|
|
0
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 $obj->suggest() |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Fetch the spelling suggestion from the Google servers. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Returns a string. Returns undef if there was an error. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub suggest { |
|
184
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
185
|
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
$self->_queries(1); |
|
187
|
|
|
|
|
|
|
|
|
188
|
0
|
|
|
|
|
|
return $self->{'_service'}->doSpellingSuggestion( |
|
189
|
|
|
|
|
|
|
$self->key(), |
|
190
|
|
|
|
|
|
|
$self->phrase(), |
|
191
|
|
|
|
|
|
|
); |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 $obj->queries_exhausted() |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Returns true or false depending on whether or not the current in-memory |
|
197
|
|
|
|
|
|
|
B has exhausted the Google API 1000 query limit. |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
# Defined in Net::Google::tool |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 VERSION |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
1.0 |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 DATE |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
$Date: 2005/03/26 20:49:03 $ |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 AUTHOR |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Aaron Straup Cope |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
L |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head1 LICENSE |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Copyright (c) 2002-2005, Aaron Straup Cope. All Rights Reserved. |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
This is free software, you may use it and distribute it under the same |
|
224
|
|
|
|
|
|
|
terms as Perl itself. |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=cut |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
return 1; |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
} |