The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Text::Corpus::CNN::Document - Parse CNN article for research.

SYNOPSIS

use Cwd;
use File::Spec;
use Text::Corpus::CNN;
use Data::Dump qw(dump);
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init ($INFO);
my $corpusDirectory = File::Spec->catfile (getcwd(), 'corpus_cnn');
my $corpus = Text::Corpus::CNN->new (corpusDirectory => $corpusDirectory);
$corpus->update (verbose => 1);
my $document = $corpus->getDocument (index => 0);
dump $document->getBody;
dump $document->getCategories;
dump $document->getContent;
dump $document->getDate;
dump $document->getDescription;
dump $document->getHighlights;
dump $document->getTitle;
dump $document->getUri;

DESCRIPTION

Text::Corpus::CNN::Document provides methods for accessing specific portions of CNN news articles for personnel researching and testing of information processing methods.

Read the CNN Interactive Service Agreement to ensure you abide with their Service Agreement when using this module.

CONSTRUCTOR

new

The constructor new creates an instance of the Text::Corpus::CNN::Document class with the following parameters:

htmlContent
htmlContent => '...'

htmlContent must be a string containing the HTML of the document to be parsed.

uri
uri => '...'

uri must be a string containing the URL of the document provided by htmlContent; it is also returned as the document's unique identifier with getUri.

METHODS

getBody

getBody ()

getBody returns an array reference of strings of sentences that are the body of the document.

getCategories

getCategories ()

getCategories returns an array reference of strings of categories assigned to the document. They are the phrases and words extracted from the /html/head/meta[@name="KEYWORDS"] field in the HTML of the document, from the 'RELATED TOPICS' section of the document, and from the URL of the document.

getContent

getContent ()

getContent returns an array reference of strings of sentences that form the content of the document, which are the title and body of the document.

getDate

getDate (format => '%g')

getDate returns the date and time of the article in the format speficied by format that uses the print directives of Date::Manip::Date. The default is to return the date and time in RFC2822 format.

getDescription

getDescription ()

getDescription returns an array reference of strings of sentences, usually one, that describes the document content. It is from the /html/head/meta[@name="description"] field in the HTML of the document.

getHighlights

getHighlights ()

getHighlights returns an array reference of the highlights of the document.

getTitle

getTitle ()

getTitle returns an array reference of strings, usually one, of the title of the document.

getUri

getUri ()

getUri returns the URL of the document.

INSTALLATION

For installation instructions see Text::Corpus::CNN.

AUTHOR

Jeff Kubina<jeff.kubina@gmail.com>

COPYRIGHT

Copyright (c) 2009 Jeff Kubina. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

KEYWORDS

cnn, cable news network, english corpus, information processing

SEE ALSO

Read the CNN Interactive Service Agreement to ensure you abide with their Service Agreement when using this module.

Date::Manip::Date, HTML::TreeBuilder::XPath, Lingua::EN::Sentence, Log::Log4perl,