| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Thesaurus::Aiksaurus; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
25292
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
36
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
40
|
|
|
5
|
1
|
|
|
1
|
|
1307
|
use String::ShellQuote; |
|
|
1
|
|
|
|
|
894
|
|
|
|
1
|
|
|
|
|
637
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Text::Thesaurus::Aiksaurus - The great new Text::Thesaurus::Aiksaurus! |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.0.0 |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.0.0'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Text::Thesaurus::Aiksaurus; |
|
23
|
|
|
|
|
|
|
use Data::Dumper; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $ata=Text::Thesaurus::Aiksaurus->new; |
|
26
|
|
|
|
|
|
|
my %h=$ata->search('test'); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
print join("\n", keys(%h)); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 METHODS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 new |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
|
38
|
0
|
|
|
0
|
1
|
|
my $self={error=>undef, errorString=>undef}; |
|
39
|
0
|
|
|
|
|
|
bless $self; |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return $self; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 search |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
This searches the aiksaurus for the specified word. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
%returnedH=$ata->search($word); |
|
49
|
|
|
|
|
|
|
if($ata->{error}){ |
|
50
|
|
|
|
|
|
|
#handles it if it errored |
|
51
|
|
|
|
|
|
|
print "It errored... ".$ata->{error}; |
|
52
|
|
|
|
|
|
|
}else{ |
|
53
|
|
|
|
|
|
|
my $int=0; |
|
54
|
|
|
|
|
|
|
if(defined($returnedH{'%misspelled'})){ |
|
55
|
|
|
|
|
|
|
#handles it if it misspelled |
|
56
|
|
|
|
|
|
|
while(defined($returnedH{'%misspelled'}[$int])){ |
|
57
|
|
|
|
|
|
|
print $returnedH{'%misspelled'}[$int]."\n"; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$int++; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
}else{ |
|
62
|
|
|
|
|
|
|
#handles it if it was not misspelled |
|
63
|
|
|
|
|
|
|
my @returnedHkeys=keys(%returnedH); |
|
64
|
|
|
|
|
|
|
while(defined($returnedHkeys[$int])){ |
|
65
|
|
|
|
|
|
|
print $returnedHkeys[$int].":\n"; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $int2==0; |
|
68
|
|
|
|
|
|
|
while(){ |
|
69
|
|
|
|
|
|
|
print ' '.$returnedH{$returnedHkeys[$int]}[$int2]; |
|
70
|
|
|
|
|
|
|
$int2++; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$int++; |
|
74
|
|
|
|
|
|
|
}; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub search{ |
|
81
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
82
|
0
|
|
|
|
|
|
my $word=$_[1]; |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my $wordquote=shell_quote($word); |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $search=`aiksaurus $wordquote`; |
|
87
|
0
|
|
|
|
|
|
my $exitcode=$? >> 8; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
#error if it got a -1... not in path |
|
90
|
0
|
0
|
|
|
|
|
if ($? == -1) { |
|
91
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
92
|
0
|
|
|
|
|
|
$self->{errorString}='"aiksaurus" not found in the current path'; |
|
93
|
0
|
|
|
|
|
|
warn('Text-Thesaurus-Aiksaurus search:1: '.$self->{errorString}); |
|
94
|
0
|
|
|
|
|
|
return undef; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#error if it is something other than 0 |
|
98
|
0
|
0
|
|
|
|
|
if (!($? == 0)) { |
|
99
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
100
|
0
|
|
|
|
|
|
$self->{errorString}='"aiksaurus" exit with a non-zero'; |
|
101
|
0
|
|
|
|
|
|
warn('Text-Thesaurus-Aiksaurus search:2: '.$self->{errorString}); |
|
102
|
0
|
|
|
|
|
|
return undef; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
#used for holding the returned information |
|
106
|
0
|
|
|
|
|
|
my %returnedH; |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
#split |
|
109
|
0
|
|
|
|
|
|
my @searchA=split(/\n/, $search); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
#this handles it if does not match it |
|
112
|
0
|
0
|
|
|
|
|
if ($searchA[0] =~ /^\*/) { |
|
113
|
0
|
|
|
|
|
|
my $int=2; |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$returnedH{'%misspelled'}=[]; |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
my $int2=0; |
|
118
|
0
|
|
|
|
|
|
while (defined($searchA[$int])) { |
|
119
|
0
|
|
|
|
|
|
$searchA[$int]=~s/^\t//g; |
|
120
|
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
$returnedH{'%misspelled'}[$int2]=$searchA[$int]; |
|
122
|
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
$int2++; |
|
124
|
0
|
|
|
|
|
|
$int++; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
return %returnedH; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
#if we get here, it means it was matched and we should break it apart |
|
131
|
0
|
|
|
|
|
|
my $int=0; |
|
132
|
0
|
|
|
|
|
|
my $last=''; |
|
133
|
0
|
|
|
|
|
|
while (defined($searchA[$int])) { |
|
134
|
|
|
|
|
|
|
#used for checking if it has been matched or not |
|
135
|
0
|
|
|
|
|
|
my $matched=0; |
|
136
|
|
|
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
if ($searchA[$int] =~ /^=/) { |
|
138
|
|
|
|
|
|
|
#removes the stuff around the word |
|
139
|
0
|
|
|
|
|
|
$searchA[$int]=~s/^=== //; |
|
140
|
0
|
|
|
|
|
|
$searchA[$int]=~s/ ===*//; |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
#sets the last word |
|
143
|
0
|
|
|
|
|
|
$last=$searchA[$int]; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
#creates the array that will hold the possibilities |
|
146
|
0
|
|
|
|
|
|
$returnedH{$last}=[]; |
|
147
|
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
$matched=1; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
#match the blank lines between words |
|
152
|
0
|
0
|
|
|
|
|
if ($searchA[$int] =~ /^$/) { |
|
153
|
0
|
|
|
|
|
|
$matched=1; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
#if it is not matched at this point, it is a list of words |
|
157
|
0
|
0
|
|
|
|
|
if (!$matched) { |
|
158
|
0
|
|
|
|
|
|
my @words=split(/\,\ /, $searchA[$int]); |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
my $int2=0; |
|
161
|
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
while (defined($words[$int2])) { |
|
163
|
0
|
|
|
|
|
|
$returnedH{$last}[$int2]=$words[$int2]; |
|
164
|
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
$int2++; |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
$int++; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
return %returnedH; |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 errorblank |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This is a internal function. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub errorblank{ |
|
182
|
0
|
|
|
0
|
1
|
|
$_[0]->{error}=undef; |
|
183
|
0
|
|
|
|
|
|
$_[1]->{errorString}=''; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 ERROR CODES |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 1 |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Failed to execute aiksaurus. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 2 |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
It exited with a non-zero status. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 RETURNED HASH |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
If the only key in the returned has is '%misspelled', it aiksaurus |
|
199
|
|
|
|
|
|
|
regards it as being mis-spelled. The key is a array of possible matches. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Each key in the returned hash is a main word containing various other ones |
|
202
|
|
|
|
|
|
|
with similar meanings. Each key is a array containing the other words. |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 AUTHOR |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 BUGS |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
211
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
212
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 SUPPORT |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
perldoc Text::Thesaurus::Aiksaurus |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
You can also look for information at: |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=over 4 |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
L |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
L |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
L |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=item * Search CPAN |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
L |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=back |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
Copyright 2009 Zane C. Bowers, all rights reserved. |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
255
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=cut |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
1; # End of Text::Thesaurus::Aiksaurus |