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

Revision 1741 (checked in by miyagawa, 14 years ago)

merge from hackathon-summary

Line 
1 package Plagger::Plugin::Summary::English;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use Lingua::EN::Summarize ();
6
7 sub register {
8     my($self, $context) = @_;
9     $context->autoload_plugin({ module => 'Filter::GuessLanguage' });
10     $context->register_hook(
11         $self,
12         'summarizer.summarize' => \&summarize,
13     );
14 }
15
16 sub summarize {
17     my($self, $context, $args) = @_;
18
19     my $lang = $args->{entry}->language || $args->{feed}->language;
20     return unless $lang && $lang eq 'en';
21
22     Lingua::EN::Summarize::summarize( $args->{text}->plaintext );
23 }
24
25 1;
26 __END__
27
28 =head1 NAME
29
30 Plagger::Plugin::Summary::English - uses Lingua::EN::Summarizer to generate summary
31
32 =head1 SYNOPSIS
33
34   - module: Summary::English
35
36 =head1 DESCRIPTION
37
38 This plugin uses Lingua::EN::Summary to generate summary, if entry language is in English.
39
40 =head1 AUTHOR
41
42 Tatsuhiko Miyagawa
43
44 =head1 SEE ALSO
45
46 L<Plagger>, L<Filter::GuessLanguage>, L<Lignau::EN::Summarize>
47
48 =cut
Note: See TracBrowser for help on using the browser.