| 1 | package Text::Corpus::CNN::Document; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use HTML::TreeBuilder::XPath; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Lingua::EN::Sentence qw(get_sentences); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Date::Manip; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Exporter (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | $VERSION = '1.02'; | |||||||||||||||||||||||||||
| 12 | 1 | @ISA = qw(); | |||||||||||||||||||||||||||
| 13 | 1 | @EXPORT = qw(); | |||||||||||||||||||||||||||
| 14 | 1 | @EXPORT_OK = qw(); | |||||||||||||||||||||||||||
| 15 | 1 | %EXPORT_TAGS = (); | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | #12345678901234567890123456789012345678901234 | ||||||||||||||||||||||||||||
| 19 | #Parse CNN article for research. | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =head1 NAME | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | C<Text::Corpus::CNN::Document> - Parse CNN article for research. | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | use Cwd; | ||||||||||||||||||||||||||||
| 28 | use File::Spec; | ||||||||||||||||||||||||||||
| 29 | use Text::Corpus::CNN; | ||||||||||||||||||||||||||||
| 30 | use Data::Dump qw(dump); | ||||||||||||||||||||||||||||
| 31 | use Log::Log4perl qw(:easy); | ||||||||||||||||||||||||||||
| 32 | Log::Log4perl->easy_init ($INFO); | ||||||||||||||||||||||||||||
| 33 | my $corpusDirectory = File::Spec->catfile (getcwd(), 'corpus_cnn'); | ||||||||||||||||||||||||||||
| 34 | my $corpus = Text::Corpus::CNN->new (corpusDirectory => $corpusDirectory); | ||||||||||||||||||||||||||||
| 35 | $corpus->update (verbose => 1); | ||||||||||||||||||||||||||||
| 36 | my $document = $corpus->getDocument (index => 0); | ||||||||||||||||||||||||||||
| 37 | dump $document->getBody; | ||||||||||||||||||||||||||||
| 38 | dump $document->getCategories; | ||||||||||||||||||||||||||||
| 39 | dump $document->getContent; | ||||||||||||||||||||||||||||
| 40 | dump $document->getDate; | ||||||||||||||||||||||||||||
| 41 | dump $document->getDescription; | ||||||||||||||||||||||||||||
| 42 | dump $document->getHighlights; | ||||||||||||||||||||||||||||
| 43 | dump $document->getTitle; | ||||||||||||||||||||||||||||
| 44 | dump $document->getUri; | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | C<Text::Corpus::CNN::Document> provides methods for accessing specific | ||||||||||||||||||||||||||||
| 49 | portions of CNN news articles for personnel researching and testing of information | ||||||||||||||||||||||||||||
| 50 | processing methods. | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | Read the CNN Interactive Service Agreement to ensure you abide with their | ||||||||||||||||||||||||||||
| 53 | Service Agreement when using this module. | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =head1 CONSTRUCTOR | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =head2 C<new> | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | The constructor C<new> creates an instance of the C<Text::Corpus::CNN::Document> | ||||||||||||||||||||||||||||
| 60 | class with the following parameters: | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =over | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =item C<htmlContent> | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | htmlContent => '...' | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | C<htmlContent> must be a string containing the HTML of the document to be parsed. The | ||||||||||||||||||||||||||||
| 69 | string should already be encoded as a Perl internal string. | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =item C<uri> | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | uri => '...' | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | C<uri> must be a string containing the URL of the document provided by C<htmlContent>; it is | ||||||||||||||||||||||||||||
| 76 | also returned as the document's unique identifier with C<getUri>. | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =item C<encoding> | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | encoding => '...' | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | C<encoding> is the encoding that the HTML content of the document uses. It is | ||||||||||||||||||||||||||||
| 83 | returned by C<getEncoding>. | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =back | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =cut | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | # htmlContent => 'html of page' to object. | ||||||||||||||||||||||||||||
| 90 | sub new | ||||||||||||||||||||||||||||
| 91 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 92 | 0 | my ($Class, %Parameters) = @_; | |||||||||||||||||||||||||||
| 93 | 0 | ▶ | my $Self = bless {}, ref($Class) || $Class; | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $Class || $Class
MC/DC0%0/2
ref $Class || $Class
ref $Class
$Class
Truth table0%0/3
A || B
A= ref $ClassB= $Class
| |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | $Self->{htmlParser} = HTML::TreeBuilder::XPath->new; | |||||||||||||||||||||||||||
| 96 | 0 | $Self->{htmlContent} = $Parameters{htmlContent}; | |||||||||||||||||||||||||||
| 97 | 0 | $Self->{encoding} = $Parameters{encoding}; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | # assuming here that the paser will convert the text from the pages encoding | ||||||||||||||||||||||||||||
| 100 | # to Perl's internal string representation. | ||||||||||||||||||||||||||||
| 101 | 0 | $Self->{htmlParser}->parse($Self->{htmlContent}); | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | # store the doc id and url. | ||||||||||||||||||||||||||||
| 104 | 0 | ▶ | $Self->{uri} = $Parameters{uri} if exists $Parameters{uri}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 0 | return $Self; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head1 METHODS | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =head2 C<getBody> | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | getBody () | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | C<getBody> returns an array reference of strings of sentences that are the body of the document. | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =cut | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | # returns the body of the article. | ||||||||||||||||||||||||||||
| 119 | sub getBody | ||||||||||||||||||||||||||||
| 120 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getBody: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 121 | 0 | my $Self = shift; | |||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | # if body already exists, return it now. | ||||||||||||||||||||||||||||
| 124 | 0 | ▶ | return $Self->{body} if exists $Self->{body}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # get the article body. | ||||||||||||||||||||||||||||
| 127 | 0 | my @linesOfText = $Self->{htmlParser}->findvalues('/html/body/div/div/div/div/div/p'); | |||||||||||||||||||||||||||
| 128 | 0 | ▶ | @linesOfText = $Self->{htmlParser}->findvalues('/html/body/div/div/div/div/div/div/div/div/div/p') if (@linesOfText == 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | # peel off wrot text. | ||||||||||||||||||||||||||||
| 131 | 0 | foreach my $line (@linesOfText) | |||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||
| 133 | 0 | $line =~ s/\s*E-mail to a friend Share this.*$//i; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | # peel off wrot text. | ||||||||||||||||||||||||||||
| 137 | 0 | my $i; | |||||||||||||||||||||||||||
| 138 | 0 | ▶ | for ($i = 0; $i < @linesOfText; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 139 | { | ||||||||||||||||||||||||||||
| 140 | 0 | ▶ | last if ($linesOfText[$i] =~ m/contributed to this report\.\s*$/i); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | last if ($linesOfText[$i] =~ m/we will send you an e-mail with a link and code to reset your password\.\s*$/i); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | 0 | $#linesOfText = $i - 1; | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | # return the title and lines of body text. | ||||||||||||||||||||||||||||
| 146 | 0 | my $body = \@linesOfText; | |||||||||||||||||||||||||||
| 147 | 0 | $Self->_trim ($body); | |||||||||||||||||||||||||||
| 148 | 0 | $Self->{body} = $body; | |||||||||||||||||||||||||||
| 149 | 0 | return $Self->{body}; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | =head2 C<getCategories> | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | getCategories () | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | C<getCategories> returns an array reference of strings of categories assigned to the document. They are | ||||||||||||||||||||||||||||
| 157 | the phrases and words extracted from the | ||||||||||||||||||||||||||||
| 158 | C</html/head/meta[@name="KEYWORDS"]> field in the HTML of the | ||||||||||||||||||||||||||||
| 159 | document, from the 'RELATED TOPICS' section of the document, and from the URL of the document. | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | =cut | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | sub getCategories | ||||||||||||||||||||||||||||
| 164 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getCategories: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 165 | 0 | my $Self = shift; | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | # return the categories if already computed. | ||||||||||||||||||||||||||||
| 168 | 0 | ▶ | return $Self->{categories_all} if exists $Self->{categories_all}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | # get the categories. | ||||||||||||||||||||||||||||
| 171 | 0 | my @categories = $Self->{htmlParser}->findvalues('/html/head/meta[@name="KEYWORDS"]/@content'); | |||||||||||||||||||||||||||
| 172 | 0 | my @relatedCategories = $Self->{htmlParser}->findvalues('/html/body/div/div/div/div/div/div/div[@class="cnn_strylctcntr cnn_strylctcqrelt"]/ul/li'); | |||||||||||||||||||||||||||
| 173 | 0 | push @categories, @relatedCategories; | |||||||||||||||||||||||||||
| 174 | 0 | @categories = split (/\,\s*/, join (',', @categories)); | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | # extract possible categories from the url. | ||||||||||||||||||||||||||||
| 177 | 0 | my $url = $Self->getUri(); | |||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ($url =~ m|/\d+/([^/]+?)/index.html|i) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | { | ||||||||||||||||||||||||||||
| 180 | 0 | my $urlCategories = $1; | |||||||||||||||||||||||||||
| 181 | 0 | my @urlCategories = split (/\./, $urlCategories); | |||||||||||||||||||||||||||
| 182 | 0 | push @categories, @urlCategories; | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | 0 | $Self->_trim (\@categories); | |||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | # remove duplicative, cache, and return the categories. | ||||||||||||||||||||||||||||
| 187 | 0 | my %uniqueCategories = map {(lc $_, $_)} sort @categories; | |||||||||||||||||||||||||||
| 188 | 0 | @categories = grep {length ($_)} sort values %uniqueCategories; | |||||||||||||||||||||||||||
| 189 | 0 | $Self->{categories_all} = \@categories; | |||||||||||||||||||||||||||
| 190 | 0 | return $Self->{categories_all}; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | =head2 C<getContent> | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | getContent () | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | C<getContent> returns an array reference of strings of sentences that form the | ||||||||||||||||||||||||||||
| 198 | content of the document, which are the title and body of the document. | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | =cut | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | # returns the content of the article. | ||||||||||||||||||||||||||||
| 203 | sub getContent | ||||||||||||||||||||||||||||
| 204 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getContent: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 205 | 0 | my $Self = shift; | |||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | # if content already exists, return it now. | ||||||||||||||||||||||||||||
| 208 | 0 | ▶ | return $Self->{content} if exists $Self->{content}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | # get the headline. | ||||||||||||||||||||||||||||
| 211 | 0 | my @linesOfText = @{$Self->getTitle}; | |||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | # get the article content. | ||||||||||||||||||||||||||||
| 214 | 0 | push @linesOfText, @{$Self->getBody}; | |||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | # copy the first paragraph. | ||||||||||||||||||||||||||||
| 217 | 0 | my $leadParagraph = $linesOfText[0]; | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | # if the lead paragraph reoccurs, delete it, assuming it is exact. | ||||||||||||||||||||||||||||
| 220 | 0 | my $leadParagraphRepeats = 0; | |||||||||||||||||||||||||||
| 221 | 0 | ▶ | for (my $i = 1 ; $i < @linesOfText ; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | { | ||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if (index($linesOfText[$i], $leadParagraph) > -1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||
| 225 | 0 | $leadParagraphRepeats = 1; | |||||||||||||||||||||||||||
| 226 | 0 | last; | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | # pop off the lead paragraph if it repeats in the text body. | ||||||||||||||||||||||||||||
| 231 | 0 | ▶ | shift @linesOfText if ($leadParagraphRepeats); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | # peel off wrot text. | ||||||||||||||||||||||||||||
| 234 | 0 | foreach my $line (@linesOfText) | |||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||
| 236 | 0 | $line =~ s/\s*E-mail to a friend Share this.*$//i; | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | # only use lines with at least one letter or number in them. | ||||||||||||||||||||||||||||
| 240 | 0 | my @fullLines; | |||||||||||||||||||||||||||
| 241 | 0 | foreach my $line (@linesOfText) | |||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if ($line =~ m/[\p{L}\p{N}]/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | { | ||||||||||||||||||||||||||||
| 245 | 0 | push @fullLines, $line; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | # return the title and lines of body text. | ||||||||||||||||||||||||||||
| 250 | 0 | my $content = \@fullLines; | |||||||||||||||||||||||||||
| 251 | 0 | $Self->_trim ($content); | |||||||||||||||||||||||||||
| 252 | 0 | $Self->{content} = $content; | |||||||||||||||||||||||||||
| 253 | 0 | return $Self->{content}; | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | =head2 C<getDate> | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | getDate (format => '%g') | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | C<getDate> returns the date and time of the article in the format speficied by C<format> that uses the print | ||||||||||||||||||||||||||||
| 261 | directives of L<Date::Manip::Date|Date::Manip::Date/PRINTF_DIRECTIVES>. | ||||||||||||||||||||||||||||
| 262 | The default is to return the date and time in RFC2822 format. | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | =cut | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | # return the date of the article | ||||||||||||||||||||||||||||
| 267 | sub getDate | ||||||||||||||||||||||||||||
| 268 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getDate: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||
| 269 | 0 | my ($Self, %Parameters) = @_; | |||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | # get the date/time format. | ||||||||||||||||||||||||||||
| 272 | 0 | my $dateFormat = '%g'; | |||||||||||||||||||||||||||
| 273 | 0 | ▶ | $dateFormat = $Parameters{format} if (exists ($Parameters{format})); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | # if date already exists and defined, return it now. | ||||||||||||||||||||||||||||
| 276 | 0 | ▶ | return UnixDate ($Self->{date}, $dateFormat) if (exists ($Self->{date}) && defined ($Self->{date})); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $Self->{"date"} and defined $Self->{"date"}
MC/DC0%0/2
exists $Self->{"date"} and defined $Self->{"date"}
exists $Self->{"date"}
defined $Self->{"date"}
Truth table0%0/3
A and B
A= exists $Self->{"date"}B= defined $Self->{"date"}
| |||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | # if date exists but could not be parsed, returned undefined. | ||||||||||||||||||||||||||||
| 279 | 0 | ▶ | return undef if (exists ($Self->{date})); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | # get the date (for the new format). | ||||||||||||||||||||||||||||
| 282 | 0 | my $nodes = $Self->{htmlParser}->findnodes('//*[@class="cnn_strytmstmp"]/script'); | |||||||||||||||||||||||||||
| 283 | 0 | my $date = undef; | |||||||||||||||||||||||||||
| 284 | 0 | foreach my $node (@$nodes) | |||||||||||||||||||||||||||
| 285 | { | ||||||||||||||||||||||||||||
| 286 | 0 | my $javascript = $node->as_XML_compact(); | |||||||||||||||||||||||||||
| 287 | 0 | ▶ | while ($javascript =~ m/document\.write\(\'(.+?)\'\)/g) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | { | ||||||||||||||||||||||||||||
| 289 | 0 | my $parsedDate = ParseDate ($1); | |||||||||||||||||||||||||||
| 290 | 0 | ▶ | if (defined ($parsedDate) && length ($parsedDate)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $parsedDate and length $parsedDate
MC/DC0%0/2
defined $parsedDate and length $parsedDate
defined $parsedDate
length $parsedDate
Truth table0%0/3
A and B
A= defined $parsedDateB= length $parsedDate
| |||||||||||||||||||||||||||||
| 291 | { | ||||||||||||||||||||||||||||
| 292 | 0 | $date = $parsedDate; | |||||||||||||||||||||||||||
| 293 | 0 | last; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | # get the date (for the old format). | ||||||||||||||||||||||||||||
| 299 | 0 | ▶ | unless (defined ($date)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 300 | { | ||||||||||||||||||||||||||||
| 301 | 0 | my $nodes = $Self->{htmlParser}->findnodes('//*[@id="cnnTimeStamp"]/script'); | |||||||||||||||||||||||||||
| 302 | 0 | foreach my $node (@$nodes) | |||||||||||||||||||||||||||
| 303 | { | ||||||||||||||||||||||||||||
| 304 | 0 | my $javascript = $node->as_XML_compact(); | |||||||||||||||||||||||||||
| 305 | 0 | ▶ | while ($javascript =~ m/\'(.+?)\'/g) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 306 | { | ||||||||||||||||||||||||||||
| 307 | 0 | my $cnnDate = $1; | |||||||||||||||||||||||||||
| 308 | 0 | $cnnDate =~ s/updated//i; | |||||||||||||||||||||||||||
| 309 | 0 | $cnnDate =~ s/\-//g; | |||||||||||||||||||||||||||
| 310 | 0 | $cnnDate =~ s/\(.*$//g; | |||||||||||||||||||||||||||
| 311 | 0 | $cnnDate =~ s/\s+/ /g; | |||||||||||||||||||||||||||
| 312 | 0 | ▶ | if ($cnnDate =~ m/(\w+) (\d+)[, ]+(\d{4}) (\d{2})(\d{2}) (\w+)/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 313 | { | ||||||||||||||||||||||||||||
| 314 | 0 | $cnnDate = "$1 $2 $4:$5 $6 $3"; | |||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | 0 | my $parsedDate = ParseDate ($cnnDate); | |||||||||||||||||||||||||||
| 317 | 0 | ▶ | if (defined ($parsedDate) && length ($parsedDate)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $parsedDate and length $parsedDate
MC/DC0%0/2
defined $parsedDate and length $parsedDate
defined $parsedDate
length $parsedDate
Truth table0%0/3
A and B
A= defined $parsedDateB= length $parsedDate
| |||||||||||||||||||||||||||||
| 318 | { | ||||||||||||||||||||||||||||
| 319 | 0 | $date = $parsedDate; | |||||||||||||||||||||||||||
| 320 | 0 | last; | |||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | # return the date. | ||||||||||||||||||||||||||||
| 327 | 0 | ▶ | return undef unless defined $date; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 328 | 0 | $Self->{date} = $date; | |||||||||||||||||||||||||||
| 329 | 0 | return UnixDate ($Self->{date}, $dateFormat); | |||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | =head2 C<getDescription> | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | getDescription () | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | C<getDescription> returns an array reference of strings of sentences, usually one, that | ||||||||||||||||||||||||||||
| 337 | describes the document content. It is from the C</html/head/meta[@name="description"]> | ||||||||||||||||||||||||||||
| 338 | field in the HTML of the document. | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | =cut | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | sub getDescription | ||||||||||||||||||||||||||||
| 343 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getDescription: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 344 | 0 | my $Self = shift; | |||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | # return the description if already computed. | ||||||||||||||||||||||||||||
| 347 | 0 | ▶ | return $Self->{description} if exists $Self->{description}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | # get the $description. | ||||||||||||||||||||||||||||
| 350 | 0 | my @descriptions = $Self->{htmlParser}->findvalues('/html/head/meta[@name="description"]/@content'); | |||||||||||||||||||||||||||
| 351 | 0 | $Self->_trim (\@descriptions); | |||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | # pull out the sentences. | ||||||||||||||||||||||||||||
| 354 | 0 | my @sentences = (); | |||||||||||||||||||||||||||
| 355 | 0 | foreach my $description (@descriptions) | |||||||||||||||||||||||||||
| 356 | { | ||||||||||||||||||||||||||||
| 357 | 0 | ▶ | next unless defined $description; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 358 | 0 | ▶ | next unless length $description; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | 0 | push @sentences, @{get_sentences ($description)}; | |||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 0 | my $description = \@sentences; | |||||||||||||||||||||||||||
| 363 | 0 | $Self->_trim ($description); | |||||||||||||||||||||||||||
| 364 | 0 | $Self->{description} = $description; | |||||||||||||||||||||||||||
| 365 | 0 | return $Self->{description}; | |||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | =head2 C<getEncoding> | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | getEncoding () | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | C<getEncoding> returns the original encoding used by the HTML of the document. | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | =cut | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | sub getEncoding | ||||||||||||||||||||||||||||
| 378 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getEncoding: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 379 | 0 | my $Self = shift; | |||||||||||||||||||||||||||
| 380 | 0 | ▶ | return $Self->{encoding} if exists $Self->{encoding}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 381 | 0 | return undef; | |||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | =head2 C<getHighlights> | ||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | getHighlights () | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | C<getHighlights> returns an array reference of the highlights of the document. | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | =cut | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | sub getHighlights | ||||||||||||||||||||||||||||
| 394 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getHighlights: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 395 | 0 | my $Self = shift; | |||||||||||||||||||||||||||
| 396 | 0 | ▶ | return $Self->{highlights} if exists $Self->{highlights}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | # get the categories. | ||||||||||||||||||||||||||||
| 399 | 0 | my @possibleHighlights = $Self->{htmlParser}->findvalues('/html/body/div/div/div/div/div/div/div/ul[@class="cnn_bulletbin cnnStryHghLght"]/li'); | |||||||||||||||||||||||||||
| 400 | 0 | ▶ | @possibleHighlights = $Self->{htmlParser}->findvalues('/html/body/div/div/div/div[@id="cnnHeaderRightCol"]/ul/li') if (@possibleHighlights == 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 401 | 0 | ▶ | @possibleHighlights = $Self->{htmlParser}->findvalues('/html/body/div/div/div/div/div[@id="cnnHeaderRightCol"]/ul/li') if (@possibleHighlights == 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | 0 | my @highlights= (); | |||||||||||||||||||||||||||
| 404 | 0 | foreach my $highlight (@possibleHighlights) | |||||||||||||||||||||||||||
| 405 | { | ||||||||||||||||||||||||||||
| 406 | 0 | ▶ | next if ($highlight eq 'Story Highlights'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 407 | 0 | ▶ | last if ($highlight =~ m/^Next Article/i); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 408 | 0 | push @highlights, $highlight; | |||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||
| 410 | 0 | $Self->_trim (\@highlights); | |||||||||||||||||||||||||||
| 411 | 0 | $Self->{highlights} = \@highlights; | |||||||||||||||||||||||||||
| 412 | 0 | return $Self->{highlights}; | |||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | =head2 C<getHtml> | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | getHtml () | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | C<getHtml> returns the HTML of the document as a string. | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | =cut | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | sub getHtml | ||||||||||||||||||||||||||||
| 425 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getHtml: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 426 | 0 | my $Self = shift; | |||||||||||||||||||||||||||
| 427 | 0 | ▶ | return $Self->{htmlContent} if exists $Self->{htmlContent}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 428 | 0 | return undef; | |||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | =head2 C<getTitle> | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | getTitle () | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | C<getTitle> returns an array reference of strings, usually one, of the title of the document. | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | =cut | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | # return the title of the article | ||||||||||||||||||||||||||||
| 441 | sub getTitle | ||||||||||||||||||||||||||||
| 442 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getTitle: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 443 | 0 | my $Self = shift; | |||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | # if title already exists, return it now. | ||||||||||||||||||||||||||||
| 446 | 0 | ▶ | return $Self->{title} if exists $Self->{title}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | # get the headline. | ||||||||||||||||||||||||||||
| 449 | 0 | my @titleLines = $Self->{htmlParser}->findvalues('/html/head/title/div/div/div/h1'); | |||||||||||||||||||||||||||
| 450 | 0 | ▶ | unless (@titleLines) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 451 | { | ||||||||||||||||||||||||||||
| 452 | 0 | @titleLines = $Self->{htmlParser}->findvalues('/html/head/title'); | |||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||
| 454 | 0 | foreach my $line (@titleLines) | |||||||||||||||||||||||||||
| 455 | { | ||||||||||||||||||||||||||||
| 456 | 0 | $line =~ s/\s*\-\s*CNN\.com\s*$//i; | |||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | # return the title. | ||||||||||||||||||||||||||||
| 460 | 0 | my $title = [@titleLines]; | |||||||||||||||||||||||||||
| 461 | 0 | $Self->_trim ($title); | |||||||||||||||||||||||||||
| 462 | 0 | $Self->{title} = $title; | |||||||||||||||||||||||||||
| 463 | 0 | return $Self->{title}; | |||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | =head2 C<getUri> | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | getUri () | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | C<getUri> returns the URL of the document. | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | =cut | ||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | sub getUri | ||||||||||||||||||||||||||||
| 475 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
getUri: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 476 | 0 | my $Self = shift; | |||||||||||||||||||||||||||
| 477 | 0 | return $Self->{uri}; | |||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | # trims off white space from the beginning and end of a string. | ||||||||||||||||||||||||||||
| 481 | sub _trim | ||||||||||||||||||||||||||||
| 482 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_trim: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 483 | 0 | my $Self = shift; | |||||||||||||||||||||||||||
| 484 | 0 | my $TextLinesToTrim = shift; | |||||||||||||||||||||||||||
| 485 | 0 | foreach my $line (@$TextLinesToTrim) | |||||||||||||||||||||||||||
| 486 | { | ||||||||||||||||||||||||||||
| 487 | 0 | $line =~ s/^\s+//; | |||||||||||||||||||||||||||
| 488 | 0 | $line =~ s/\s+$//; | |||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||
| 490 | 0 | return undef; | |||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | # since we need to call delete on html::treebuilder, we implement DESTORY. | ||||||||||||||||||||||||||||
| 494 | sub DESTROY | ||||||||||||||||||||||||||||
| 495 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 496 | 0 | my $Self = shift; | |||||||||||||||||||||||||||
| 497 | 0 | ▶ | $Self->{htmlParser}->delete if exists $Self->{htmlParser}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 498 | 0 | undef $Self; | |||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | =head1 INSTALLATION | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | For installation instructions see L<Text::Corpus::CNN>. | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | =head1 BUGS | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | This module uses xpath expressions to extract links and text which may become invalid | ||||||||||||||||||||||||||||
| 508 | as the format of various pages change, causing a lot of bugs. | ||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | Please email bugs reports or feature requests to C<text-corpus-cnn@rt.cpan.org>, or through | ||||||||||||||||||||||||||||
| 511 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Text-Corpus-CNN>. The author | ||||||||||||||||||||||||||||
| 512 | will be notified and you can be automatically notified of progress on the bug fix or feature request. | ||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | Jeff Kubina<jeff.kubina@gmail.com> | ||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | Copyright (c) 2009 Jeff Kubina. All rights reserved. | ||||||||||||||||||||||||||||
| 521 | This program is free software; you can redistribute | ||||||||||||||||||||||||||||
| 522 | it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | The full text of the license can be found in the | ||||||||||||||||||||||||||||
| 525 | LICENSE file included with this module. | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | =head1 KEYWORDS | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | cnn, cable news network, english corpus, information processing | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | =begin html | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | Read the <a href="http://www.cnn.com/interactive_legal.html">CNN Interactive Service Agreement</a> to ensure you abide with their | ||||||||||||||||||||||||||||
| 536 | Service Agreement when using this module. | ||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | =end html | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | L<Date::Manip::Date>, L<HTML::TreeBuilder::XPath>, L<Lingua::EN::Sentence>, L<Log::Log4perl>, | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | =cut | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | 1 | 1; | |||||||||||||||||||||||||||
| 545 | # The preceding line will help the module return a true value | ||||||||||||||||||||||||||||