source: gsdl/trunk/perllib/plugins/DateExtractor.pm@ 15918

Last change on this file since 15918 was 15887, checked in by mdewsnip, 16 years ago

Added "use strict" to the few files that were missing it, and fixing resulting problems in MediaWikiPlug.pm.

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1package DateExtractor;
2
3use DateExtract;
4use PrintInfo;
5use strict;
6
7BEGIN {
8 @DateExtractor::ISA = ('PrintInfo');
9}
10
11my $arguments = [
12 { 'name' => "extract_historical_years",
13 'desc' => "{DateExtractor.extract_historical_years}",
14 'type' => "flag",
15 'reqd' => "no" },
16 { 'name' => "maximum_year",
17 'desc' => "{DateExtractor.maximum_year}",
18 'type' => "int",
19 'deft' => (localtime)[5]+1900,
20 'char_length' => "4",
21 #'range' => "2,100",
22 'reqd' => "no"},
23 { 'name' => "maximum_century",
24 'desc' => "{DateExtractor.maximum_century}",
25 'type' => "string",
26 'deft' => "-1",
27 'reqd' => "no" },
28 { 'name' => "no_bibliography",
29 'desc' => "{DateExtractor.no_bibliography}",
30 'type' => "flag",
31 'reqd' => "no"},
32 ];
33
34my $options = { 'name' => "DateExtractor",
35 'desc' => "{DateExtractor.desc}",
36 'abstract' => "yes",
37 'inherits' => "yes",
38 'args' => $arguments };
39
40
41sub new {
42 my ($class) = shift (@_);
43 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
44 push(@$pluginlist, $class);
45
46 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
47 push(@{$hashArgOptLists->{"OptList"}},$options);
48
49 my $self = new PrintInfo($pluginlist, $inputargs, $hashArgOptLists, 1);
50
51 return bless $self, $class;
52
53}
54
55
56# extract metadata
57sub extract_date_metadata {
58
59 my $self = shift (@_);
60 my ($doc_obj) = @_;
61
62 if($self->{'extract_historical_years'}) {
63 my $thissection = $doc_obj->get_top_section();
64 while (defined $thissection) {
65
66 my $text = $doc_obj->get_text($thissection);
67 &DateExtract::get_date_metadata($text, $doc_obj,
68 $thissection,
69 $self->{'no_bibliography'},
70 $self->{'maximum_year'},
71 $self->{'maximum_century'});
72 $thissection = $doc_obj->get_next_section ($thissection);
73 }
74 }
75}
76
77
781;
Note: See TracBrowser for help on using the repository browser.