root/trunk/plagger/lib/Plagger/Plugin/Summary/Japanese.pm

Revision 1820 (checked in by ko, 14 years ago)

configuration support for Summart::Japanese

Line 
1 package Plagger::Plugin::Summary::Japanese;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use Lingua::JA::Summarize::Extract;
6
7 sub register {
8     my($self, $context) = @_;
9     $context->autoload_plugin({ module => 'Filter::GuessLanguage' });
10     $self->{extracter} = Lingua::JA::Summarize::Extract->new($self->conf);
11     $context->register_hook(
12         $self,
13         'summarizer.summarize' => \&summarize,
14     );
15 }
16
17 sub summarize {
18     my($self, $context, $args) = @_;
19
20     my $lang = $args->{entry}->language || $args->{feed}->language;
21     return unless $lang && $lang eq 'ja';
22
23     my $summary = $self->{extracter}->extract($args->{entry}->body->plaintext);
24     $summary->length(128) unless $self->conf->{length};
25     return $summary->as_string;
26 }
27
28 1;
29 __END__
30
31 =head1 NAME
32
33 Plagger::Plugin::Summary::Japanese -
34
35 =head1 SYNOPSIS
36
37   - module: Summary::Japanese
38
39 =head1 DESCRIPTION
40
41 XXX Write the description for Summary::Japanese
42
43 =head1 CONFIG
44
45 XXX Document configuration variables if any.
46
47 =head1 AUTHOR
48
49 Tatsuhiko Miyagawa
50
51 =head1 SEE ALSO
52
53 L<Plagger>, L<Lingua::JA::Summarize::Extract>
54
55 =cut
Note: See TracBrowser for help on using the browser.