Text::Summary::MediaWiki - Produce a short summary from MediaWiki markup
use Text::Summary::MediaWiki; my $s = Text::Summary::MediaWiki->new( url => "http://en.wikipedia.org/wiki/", # Trailing / is required get => sub { my($url) = @_; # return markup of page at URL }); print $s->get("Perl");
Produces short summaries from MediaWiki markup. This has been mostly tested with Wikipedia but this should work for any wiki using MediaWiki markup.
Note that making requests to Wikipedia for each page is considered rather rude, if you need a high query volume use a local database dump (I use Parse::MediaWikiDump).
The new method takes a parameter hash containing the following:
new
url
Required, the URL used to identify the instance of MediaWiki to produce summaries for. This should be the base path to the instance.
get
Required, a callback to fetch the actual text, this is required so the code can get additional pages if redirected.
redirect_limit
Optional, a limit for redirection, default 5.
approx_length
Optional, approximate length of summary to produce (in characters), default 200.
Given the name of an article fetches it and generates a summary.
If called in array context returns the summary and the URL it can be found at.
Generates a summary from text in MediaWiki format.
David Leadbeater <dgl at dgl.cx>
<dgl at dgl.cx
Copyright 2006 David Leadbeater, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Text::Summary::MediaWiki, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::Summary::MediaWiki
CPAN shell
perl -MCPAN -e shell install Text::Summary::MediaWiki
For more information on module installation, please visit the detailed CPAN module installation guide.