line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::WolframAlpha::ValidateQuery; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
16
|
use 5.008008; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
554
|
use WWW::WolframAlpha::Assumptions; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
10
|
1
|
|
|
1
|
|
749
|
use WWW::WolframAlpha::Warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
11
|
1
|
|
|
1
|
|
559
|
use WWW::WolframAlpha::Error; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
691
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
16
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
17
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# This allows declaration use WWW::WolframAlpha ':all'; |
20
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
21
|
|
|
|
|
|
|
# will save memory. |
22
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
23
|
|
|
|
|
|
|
) ] ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our @EXPORT = qw( |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = '1.0'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
33
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my %options = @_; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $self = {}; |
38
|
0
|
|
|
|
|
|
while(my($key, $val) = each %options) { |
39
|
0
|
|
|
|
|
|
my $lkey = lc($key); |
40
|
0
|
|
|
|
|
|
$self->{$lkey} = $val; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my ($timing,$parsetiming,$assumptions,$warnings,$error,$success); |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
@{$self->{'warnings'}} = (); |
|
0
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$self->{'success'} = 0; |
48
|
0
|
|
|
|
|
|
$self->{'error'} = 1; |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if ($self->{'xmlo'}) { |
51
|
0
|
|
0
|
|
|
|
$timing = $self->{'xmlo'}->{'timing'} || undef; |
52
|
0
|
|
0
|
|
|
|
$parsetiming = $self->{'xmlo'}->{'parsetiming'} || undef; |
53
|
0
|
|
0
|
|
|
|
$assumptions = $self->{'xmlo'}->{'assumptions'} || undef; |
54
|
0
|
|
0
|
|
|
|
$success = $self->{'xmlo'}->{'success'} || undef; |
55
|
0
|
|
0
|
|
|
|
$error = $self->{'xmlo'}->{'error'} || undef; |
56
|
0
|
|
0
|
|
|
|
$warnings = $self->{'xmlo'}->{'warnings'} || undef; |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
$self->{'timing'} = $timing if defined $timing; |
59
|
0
|
0
|
|
|
|
|
$self->{'parsetiming'} = $parsetiming if defined $parsetiming; |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
0
|
|
|
|
if (defined $success && $success eq 'true') { |
62
|
0
|
|
|
|
|
|
$self->{'success'} = 1; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
0
|
|
|
|
if (defined $error && $error eq 'false') { |
|
|
0
|
0
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$self->{'error'} = 0; |
67
|
|
|
|
|
|
|
} elsif (defined $error && $error ne 'false') { |
68
|
0
|
|
|
|
|
|
$self->{'error'} = WWW::WolframAlpha::Error->new($error); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$self->{'assumptions'} = WWW::WolframAlpha::Assumptions->new($assumptions); |
73
|
0
|
|
|
|
|
|
$self->{'warnings'} = WWW::WolframAlpha::Warnings->new($warnings); |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return(bless($self, $class)); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
0
|
0
|
|
sub success {shift->{'success'};} |
79
|
0
|
|
|
0
|
0
|
|
sub error {shift->{'error'};} |
80
|
0
|
|
|
0
|
0
|
|
sub xml {shift->{'xml'};} |
81
|
0
|
|
|
0
|
0
|
|
sub xmlo {shift->{'xmlo'};} |
82
|
0
|
|
|
0
|
0
|
|
sub timing {shift->{'timing'};} |
83
|
0
|
|
|
0
|
0
|
|
sub parsetiming {shift->{'parsetiming'};} |
84
|
0
|
|
|
0
|
0
|
|
sub assumptions {shift->{'assumptions'};} |
85
|
0
|
|
|
0
|
0
|
|
sub warnings {shift->{'warnings'};} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Preloaded methods go here. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=pod |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 NAME |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
WWW::WolframAlpha::ValidateQuery |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 VERSION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
version 1.10 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SYNOPSIS |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $validatequery = $wa->validatequery( |
106
|
|
|
|
|
|
|
input => $input, |
107
|
|
|
|
|
|
|
assumption => '*C.pi-_*Movie-', |
108
|
|
|
|
|
|
|
); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
if ($validatequery->success) { |
111
|
|
|
|
|
|
|
... |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 DESCRIPTION |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 SUCCESS |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
$validatequery->success - 0/1, tells whether it was successful or not |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
$validatequery->error - 0 or L, tells whether there was an error or not |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 ATTRIBUTES |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$validatequery->timing |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
$validatequery->parsetiming |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 SECTOINS |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
$query->assumptions - L object |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
$query->warnings - L object |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 DEBUGGING |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
$validatequery->xml - raw XML |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
$validatequery->xmlo - raw XML::Simple object |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 NAME |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
WWW::WolframAlpha::ValidateQuery - Perl object returned via $wa->validatequery |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 SEE ALSO |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 AUTHOR |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Gabriel Weinberg, Eyegg@alum.mit.eduE |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Copyright (C) 2009 by Gabriel Weinberg |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
157
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
158
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 AUTHOR |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Gabriel Weinberg |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This software is copyright (c) 2009 by Gabriel Weinberg. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
169
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
__END__ |