line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Kizasi; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
646257
|
use version; our $VERSION = qv('0.02'); |
|
9
|
|
|
|
|
37096
|
|
|
9
|
|
|
|
|
56
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
762
|
use warnings; |
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
247
|
|
6
|
9
|
|
|
9
|
|
93
|
use strict; |
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
248
|
|
7
|
9
|
|
|
9
|
|
49
|
use Carp; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
1076
|
|
8
|
9
|
|
|
9
|
|
12255
|
use LWP::UserAgent; |
|
9
|
|
|
|
|
620876
|
|
|
9
|
|
|
|
|
514
|
|
9
|
9
|
|
|
9
|
|
105
|
use URI::Escape; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
780
|
|
10
|
9
|
|
|
9
|
|
16906
|
use WebService::Kizasi::Parser; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $C10E_WORD_URL = |
13
|
|
|
|
|
|
|
"http://kizasi.jp/kizapi.py?span=SPAN&kw_expr=WORD&type=coll"; |
14
|
|
|
|
|
|
|
my $KWIC_URL = "http://kizasi.jp/kizapi.py?kw_expr=WORD&type=kwic"; |
15
|
|
|
|
|
|
|
my $RANKING_URL = "http://kizasi.jp/kizapi.py?span=SPAN&type=rank"; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
|
|
|
|
|
|
my $class = shift; |
19
|
|
|
|
|
|
|
my $ua = new LWP::UserAgent; |
20
|
|
|
|
|
|
|
$ua->env_proxy; |
21
|
|
|
|
|
|
|
$ua->agent( join '/', __PACKAGE__, $VERSION ); |
22
|
|
|
|
|
|
|
bless { ua => $ua }, $class; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _get_and_parse { |
26
|
|
|
|
|
|
|
my ( $self, $uri, $keyword, $period ) = @_; |
27
|
|
|
|
|
|
|
my ($res); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$keyword = uri_escape($keyword) if ($keyword); |
30
|
|
|
|
|
|
|
$uri =~ s/SPAN/$period/ if ($period); |
31
|
|
|
|
|
|
|
$uri =~ s/WORD/$keyword/ if ($keyword); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$res = $self->{ua}->get($uri); |
34
|
|
|
|
|
|
|
WebService::Kizasi::Parser->parse($res); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _c10e_word { |
38
|
|
|
|
|
|
|
my ( $self, $keyword, $period ) = @_; |
39
|
|
|
|
|
|
|
_get_and_parse( $self, $C10E_WORD_URL, $keyword, $period ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub c10e_word_1d { |
43
|
|
|
|
|
|
|
my ( $self, $keyword ) = @_; |
44
|
|
|
|
|
|
|
$self->_c10e_word( $keyword, '24' ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub c10e_word_1w { |
48
|
|
|
|
|
|
|
my ( $self, $keyword ) = @_; |
49
|
|
|
|
|
|
|
$self->_c10e_word( $keyword, '1w' ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub c10e_word_1m { |
53
|
|
|
|
|
|
|
my ( $self, $keyword ) = @_; |
54
|
|
|
|
|
|
|
$self->_c10e_word( $keyword, '1m' ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub keyword_in_context { |
58
|
|
|
|
|
|
|
my ( $self, $keyword ) = @_; |
59
|
|
|
|
|
|
|
_get_and_parse( $self, $KWIC_URL, $keyword, '' ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _ranking { |
63
|
|
|
|
|
|
|
my ( $self, $period ) = @_; |
64
|
|
|
|
|
|
|
_get_and_parse( $self, $RANKING_URL, '', $period ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub ranking_1d { |
68
|
|
|
|
|
|
|
my $self = shift; |
69
|
|
|
|
|
|
|
$self->_ranking('24'); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub ranking_1w { |
73
|
|
|
|
|
|
|
my $self = shift; |
74
|
|
|
|
|
|
|
$self->_ranking('1w'); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub ranking_1m { |
78
|
|
|
|
|
|
|
my $self = shift; |
79
|
|
|
|
|
|
|
$self->_ranking('1m'); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
WebService::Kizasi - A Perl Interface for the Kizasi Web Services |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 VERSION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This document describes WebService::Kizasi version 0.0.1 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SYNOPSIS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
use WebService::Kizasi; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
use Encode qw(_utf8_off); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $kizapi = WebService::Kizasi->new(); |
101
|
|
|
|
|
|
|
my @result; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$result[0] = $kizapi->c10e_word_1d('CPAN'); |
104
|
|
|
|
|
|
|
$result[1] = $kizapi->c10e_word_1w('CPAN'); |
105
|
|
|
|
|
|
|
$result[2] = $kizapi->c10e_word_1m('CPAN'); |
106
|
|
|
|
|
|
|
$result[3] = $kizapi->keyword_in_context('CPAN'); |
107
|
|
|
|
|
|
|
$result[4] = $kizapi->ranking_1d; |
108
|
|
|
|
|
|
|
$result[5] = $kizapi->ranking_1w; |
109
|
|
|
|
|
|
|
$result[6] = $kizapi->ranking_1m; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
for my $result (@result) { |
112
|
|
|
|
|
|
|
my $utf8off = $result->items->[0]->title; |
113
|
|
|
|
|
|
|
_utf8_off ($utf8off); |
114
|
|
|
|
|
|
|
print $utf8off,"\n"; |
115
|
|
|
|
|
|
|
print $result->items->[0]->pubDate,"\n"; |
116
|
|
|
|
|
|
|
print $result->items->[0]->link,"\n"; |
117
|
|
|
|
|
|
|
print $result->items->[0]->guid,"\n"; |
118
|
|
|
|
|
|
|
$utf8off = $result->items->[0]->description; |
119
|
|
|
|
|
|
|
_utf8_off($utf8off); |
120
|
|
|
|
|
|
|
print $utf8off,"\n"; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 DESCRIPTION |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Kizasi.jp is the sight which discovers the "sign of change" |
126
|
|
|
|
|
|
|
(Kizasi) from blogs, and the WebService::Kizasi is a Perl |
127
|
|
|
|
|
|
|
interface to the Kizasi WebService API (Kizapi). For details, |
128
|
|
|
|
|
|
|
see http://blog.kizasi.jp/kizasi/66. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 INTERFACE |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 new |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Returns an instace of this module. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 c10e_word_1d($keyword) |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Returns WebService::Kizasi::Items, designates the |
139
|
|
|
|
|
|
|
cooccurrence (C10E) words from the keyword in 1 day. |
140
|
|
|
|
|
|
|
Keyword must be encoded as UTF-8, and the number of |
141
|
|
|
|
|
|
|
C10E words are less than 60. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 c10e_word_1w($keyword) |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Returns WebService::Kizasi::Items, designates the |
146
|
|
|
|
|
|
|
cooccurrence (C10E) words from the keyword in 1 week. |
147
|
|
|
|
|
|
|
Keyword must be encoded as UTF-8, and the number of |
148
|
|
|
|
|
|
|
C10E words are less than 60. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 c10e_word_1m($keyword) |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Returns WebService::Kizasi::Items, designates the |
153
|
|
|
|
|
|
|
cooccurrence (C10E) words from the keyword in 1 month. |
154
|
|
|
|
|
|
|
Keyword must be encoded as UTF-8, and the number of |
155
|
|
|
|
|
|
|
C10E words are less than 60. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 keyword_in_context($keyword) |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Returns WebService::Kizasi::Items, designates the |
160
|
|
|
|
|
|
|
sentenses which include the keyword. Keyword must be |
161
|
|
|
|
|
|
|
encoded as UTF-8, and the number of sentenses are |
162
|
|
|
|
|
|
|
less than 30. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 ranking_1d |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Returns WebService::Kizasi::Items, designates the |
167
|
|
|
|
|
|
|
ranking of the topics in 1 day. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 ranking_1w |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Returns WebService::Kizasi::Items, designates the |
172
|
|
|
|
|
|
|
ranking of the topics in 1 week. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 ranking_1m |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Returns WebService::Kizasi::Items, designates the |
177
|
|
|
|
|
|
|
ranking of the topics in 1 month. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
See WebService::Kizasi::Items->status and their status_message. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
WebService::Kizasi requires no configuration files, but load |
186
|
|
|
|
|
|
|
proxy settings from *_proxy environment variables. See LWP::UserAgent |
187
|
|
|
|
|
|
|
for more details. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Class::Accessor::Fast, |
192
|
|
|
|
|
|
|
XML::RSS::LibXML, |
193
|
|
|
|
|
|
|
version, |
194
|
|
|
|
|
|
|
LWP::UserAgent, |
195
|
|
|
|
|
|
|
URI::Escape, |
196
|
|
|
|
|
|
|
Test::Base. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
None reported. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
No bugs have been reported. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
207
|
|
|
|
|
|
|
C, or through the web interface at |
208
|
|
|
|
|
|
|
L. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 SEE ALSO |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
L |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head1 AUTHOR |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
DAIBA, Keiichi C<< keiichi@tokyo.pm.org >> |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Copyright (c) 2007, DAIBA, Keiichi C<< keiichi@tokyo.pm.org >>. |
222
|
|
|
|
|
|
|
All rights reserved. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
225
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. See C. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
231
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
232
|
|
|
|
|
|
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
233
|
|
|
|
|
|
|
PROVIDE THE SOFTWARE ''AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER |
234
|
|
|
|
|
|
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
235
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
236
|
|
|
|
|
|
|
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
237
|
|
|
|
|
|
|
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
238
|
|
|
|
|
|
|
NECESSARY SERVICING, REPAIR, OR CORRECTION. |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
241
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
242
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE |
243
|
|
|
|
|
|
|
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
244
|
|
|
|
|
|
|
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
245
|
|
|
|
|
|
|
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
246
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
247
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
248
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
249
|
|
|
|
|
|
|
SUCH DAMAGES. |