Changeset 1483

Show
Ignore:
Timestamp:
31.08.2000 20:05:25 (19 years ago)
Author:
sjboddie
Message:

added -out option to classifiers

Location:
trunk/gsdl/perllib
Files:
1 added
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/classify.pm

    r831 r1483  
    3737    my @classify_objects = (); 
    3838     
     39    my $outhandle = pop (@_); 
     40 
    3941    foreach $classifyoption (@$classify_list) { 
    4042 
     
    5759    map { $_ = "\"$_\""; } @$classifyoption; 
    5860    my $options = join (",", @$classifyoption); 
    59     eval ("\$classobj = new \$classname($options)"); 
     61    eval ("\$classobj = new \$classname($options, $outhandle)"); 
    6062    die "$@" if $@; 
    6163     
  • trunk/gsdl/perllib/classify/AZCompactList.pm

    r1313 r1483  
    4343package AZCompactList; 
    4444 
     45use BasClas; 
    4546use sorttools; 
     47 
     48sub BEGIN { 
     49    @ISA = ('BasClas'); 
     50} 
    4651 
    4752sub new { 
    4853    my ($class, @options) = @_; 
     54    my $self = new BasClas ($class, @_); 
    4955 
    5056    my ($metaname, $title); 
     
    7985    } 
    8086 
    81     die "AZCompactList used with no metadata name to classify by\n" 
    82     unless defined $metaname; 
     87    if (!defined $metaname) { 
     88    my $outhandle = $self->{'outhandle'}; 
     89    print $outhandle "AZCompactList used with no metadata name to classify by\n"; 
     90    die "\n"; 
     91    } 
     92 
    8393    $title = $metaname unless defined $title; 
    8494 
    85     return bless { 
    86     'list'=>{},  
    87     'listmetavalue'=>{},  
    88     'reclassify'=>{}, 
    89     'reclassifylist'=>{}, 
    90     'metaname' => $metaname, 
    91     'title' => $title, 
    92     'mingroup' => $mingroup, 
    93     'minnesting' => $minnesting, 
    94     'mincompact' => $mincompact, 
    95     'maxcompact' => $maxcompact, 
    96     'doclevel' => $doclevel, 
    97     'onlyfirst' => $onlyfirst, 
    98     'recopt' => $recopt 
    99     }, $class; 
    100  
    101  
     95    $self->{'list'} = {}; 
     96    $self->{'listmetavalue'} = {}; 
     97    $self->{'reclassify'} = {}; 
     98    $self->{'reclassifylist'} = {}; 
     99    $self->{'metaname'} = $metaname; 
     100    $self->{'title'} = $title; 
     101    $self->{'mingroup'} = $mingroup; 
     102    $self->{'minnesting'} = $minnesting; 
     103    $self->{'mincompact'} = $mincompact; 
     104    $self->{'maxcompact'} = $maxcompact; 
     105    $self->{'doclevel'} = $doclevel; 
     106    $self->{'onlyfirst'} = $onlyfirst; 
     107    $self->{'recopt'} = $recopt; 
     108 
     109    return bless $self, $class; 
    102110} 
    103111 
     
    125133 
    126134    my $metaname = $self->{'metaname'}; 
     135    my $outhandle = $self->{'outhandle'}; 
    127136 
    128137    $metaname =~ s/(\/.*)//; # grab first name in n1/n2/n3 list 
    129 ##    print STDERR "AZCompactList: processing $doc_OID for $metaname\n"; 
    130138 
    131139    if ($self->{'doclevel'} =~ /^top(level)?/i) 
     
    151159    if (defined $self->{'list'}->{$full_doc_OID})  
    152160    { 
    153         print STDERR "WARNING: AZCompactList::classify called multiple times for $full_doc_OID\n"; 
     161        print $outhandle "WARNING: AZCompactList::classify called multiple times for $full_doc_OID\n"; 
    154162    }  
    155163    $self->{'list'}->{$full_doc_OID} = [];   
     
    238246    else  
    239247    {  
    240         die "AZCompactList ERROR - couldn't find classifier \"$listname\"\n";  
     248        my $outhandle = $self->{'outhandle'}; 
     249        print $outhandle "AZCompactList ERROR - couldn't find classifier \"$listname\"\n";  
     250        die "\n"; 
    241251    } 
    242252    } 
     
    281291        eval ("\$listclassobj = new AZCompactList($args)"); 
    282292        } 
    283         die "$@" if $@; 
     293        if ($@) { 
     294        my $outhandle = $self->{'outhandle'}; 
     295        print $outhandle "$@"; 
     296        die "\n"; 
     297        } 
    284298         
    285299        $listclassobj->init(); 
     
    352366    if (!$found) 
    353367    { 
    354         print STDERR "Warning: AZCompactList::reclassify "; 
    355         print STDERR "could not find sub-node for $metavalue with doc_OID $doc_OID\n"; 
     368        print $outhandle "Warning: AZCompactList::reclassify "; 
     369        print $outhandle "could not find sub-node for $metavalue with doc_OID $doc_OID\n"; 
    356370    } 
    357371    } 
     
    503517    if ($title =~ /^[0-9]$/) {$title = '0-9';} 
    504518    elsif ($title !~ /^[A-Z]$/) { 
    505         print STDERR "AZCompactList: WARNING $classification has badly formatted title ($title)\n"; 
     519        my $outhandle = $self->{'outhandle'}; 
     520        print $outhandle "AZCompactList: WARNING $classification has badly formatted title ($title)\n"; 
    506521    } 
    507522    $classhash->{$title} = [] unless defined $classhash->{$title}; 
  • trunk/gsdl/perllib/classify/AZList.pm

    r837 r1483  
    3434package AZList; 
    3535 
     36use BasClas; 
    3637use sorttools; 
     38 
     39sub BEGIN { 
     40    @ISA = ('BasClas'); 
     41} 
    3742 
    3843sub new { 
    3944    my ($class, @options) = @_; 
     45    my $self = new BasClas ($class, @_); 
    4046 
    4147    my ($metaname, $title); 
     
    4955    } 
    5056 
    51     die "AZList used with no metadata name to classify by\n" 
    52     unless defined $metaname; 
     57    if (!defined $metaname) { 
     58    my $outhandle = $self->{'outhandle'}; 
     59    print $outhandle "AZList used with no metadata name to classify by\n"; 
     60    die "\n"; 
     61    } 
     62 
    5363    $title = $metaname unless defined $title; 
    5464 
    55     return bless { 
    56     'list'=>{}, 
    57     'metaname' => $metaname, 
    58     'title' => $title 
    59     }, $class; 
     65    $self->{'list'} = {}; 
     66    $self->{'metaname'} = $metaname; 
     67    $self->{'title'} = $title; 
     68 
     69    return bless $self, $class; 
    6070} 
    6171 
     
    8393    } 
    8494    if (defined $self->{'list'}->{$doc_OID}) { 
    85         print STDERR "WARNING: AZList::classify called multiple times for $doc_OID\n"; 
     95        my $outhandle = $self->{'outhandle'}; 
     96        print $outhandle "WARNING: AZList::classify called multiple times for $doc_OID\n"; 
    8697    }  
    8798    $self->{'list'}->{$doc_OID} = $metavalue; 
     
    164175    if ($title =~ /^[0-9]$/) {$title = '0-9';} 
    165176    elsif ($title !~ /^[A-Z]$/) { 
    166         print STDERR "AZList: WARNING $classification has badly formatted title ($title)\n"; 
     177        my $outhandle = $self->{'outhandle'}; 
     178        print $outhandle "AZList: WARNING $classification has badly formatted title ($title)\n"; 
    167179    } 
    168180    $classhash->{$title} = [] unless defined $classhash->{$title}; 
  • trunk/gsdl/perllib/classify/AZSectionList.pm

    r1250 r1483  
    4343} 
    4444 
     45sub new { 
     46    my ($class, @options) = @_; 
     47    my $self = new AZList ($class, @_); 
     48} 
     49 
    4550sub classify { 
    4651    my $self = shift (@_); 
     
    7277    } 
    7378    if (defined $self->{'list'}->{"$doc_OID.$section"}) { 
    74         print STDERR "WARNING: AZSectionList::classify called multiple times " . 
     79        my $outhandle = $self->{'outhandle'}; 
     80        print $outhandle "WARNING: AZSectionList::classify called multiple times " . 
    7581        "for $doc_OID.$section\n"; 
    7682    }  
  • trunk/gsdl/perllib/classify/DateList.pm

    r677 r1483  
    3434package DateList; 
    3535 
     36use BasClas; 
    3637use sorttools; 
     38 
     39sub BEGIN { 
     40    @ISA = ('BasClas'); 
     41} 
    3742 
    3843sub new { 
    3944    my ($class, @options) = @_; 
    40  
    41     return bless { 
    42     'list'=>{}, 
    43     }, $class; 
     45    my $self = new BasClas ($class, @_); 
     46 
     47    $self->{'list'} = {}; 
     48 
     49    return bless $self, $class; 
    4450} 
    4551 
     
    6167    if (defined $date && $date =~ /\d/) { 
    6268    if (defined $self->{'list'}->{$doc_OID}) { 
    63         print STDERR "WARNING: DateList::classify called multiple times for $doc_OID\n"; 
     69        my $outhandle = $self->{'outhandle'}; 
     70        print $outhandle "WARNING: DateList::classify called multiple times for $doc_OID\n"; 
    6471    }  
    6572    $self->{'list'}->{$doc_OID} = $date; 
  • trunk/gsdl/perllib/classify/HTML.pm

    r717 r1483  
    3333package HTML; 
    3434 
     35use BasClas; 
     36 
     37sub BEGIN { 
     38    @ISA = ('BasClas'); 
     39} 
     40 
    3541sub new { 
    3642    my ($class, @options) = @_; 
     43    my $self = new BasClas ($class, @_); 
    3744 
    3845    my ($title, $url); 
     
    4653    } 
    4754 
    48     die "Error: HTML classifier contains no 'url' option\n"  
    49     unless defined $url; 
     55    if (!defined $url) { 
     56    my $outhandle = $self->{'outhandle'}; 
     57    print $outhandle "Error: HTML classifier contains no 'url' option\n"; 
     58    die "\n"; 
     59    } 
    5060 
    5161    $title = 'Browse' unless defined $title; 
    5262 
    53     return bless { 
    54     'url' => $url, 
    55     'title' => $title 
    56     }, $class; 
     63    $self->{'url'} = $url; 
     64    $self->{'title'} = $title; 
     65 
     66    return bless $self, $class; 
    5767} 
    5868 
  • trunk/gsdl/perllib/classify/Hierarchy.pm

    r677 r1483  
    4141package Hierarchy; 
    4242 
     43use BasClas; 
    4344use util; 
    4445use cfgread; 
    4546use sorttools; 
    4647 
     48sub BEGIN { 
     49    @ISA = ('BasClas'); 
     50} 
     51 
    4752sub new { 
    4853    my ($class, @options) = @_; 
     54    my $self = new BasClas ($class, @_); 
    4955 
    5056    my $sortname = "Title"; 
     
    6571 
    6672    if (!defined ($hfile) || !defined ($metadata)) { 
    67     die "Error in options passed to Hierarchy classification\n" . 
    68         "hfile and metadata options aren't optional\n\n" . 
    69         "Options:\n" . 
    70             "hfile -- the classification structure file\n" . 
    71             "metadata -- metadata field to test against hfile\n" . 
    72                 "sort -- metadata field to sort by\n" . 
    73                 "title -- title of classification\n\n"; 
     73    my $outhandle = $self->{'outhandle'}; 
     74    print $outhandle "Error in options passed to Hierarchy classification\n"; 
     75    print $outhandle "hfile and metadata options aren't optional\n\n"; 
     76    print $outhandle "Options:\n"; 
     77    print $outhandle "hfile -- the classification structure file\n"; 
     78    print $outhandle "metadata -- metadata field to test against hfile\n"; 
     79    print $outhandle "sort -- metadata field to sort by\n"; 
     80    print $outhandle "title -- title of classification\n\n"; 
     81    die "\n"; 
    7482    } 
    7583 
     
    8189    $subjectfile = &util::filename_cat($ENV{'GSDLHOME'},"etc", $hfile); 
    8290    if (!-e $subjectfile) { 
    83         die "Hierarchy Error: Can't locate subject file $hfile\n" . 
    84         "This file should be in $collfile or $subjectfile\n"; 
    85     } 
    86     } 
    87  
    88     return bless { 
    89     'descriptorlist'=>{}, # first field in subject file 
    90     'locatorlist'=>{},    # second field in subject file 
    91     'subjectfile' => $subjectfile, 
    92     'metaname' => $metadata, 
    93     'sortname' => $sortname, 
    94     'title' => $title 
    95     }, $class; 
     91        my $outhandle = $self->{'outhandle'}; 
     92        print $outhandle "Hierarchy Error: Can't locate subject file $hfile\n"; 
     93        print $outhandle "This file should be in $collfile or $subjectfile\n"; 
     94        die "\n"; 
     95    } 
     96    } 
     97 
     98    $self->{'descriptorlist'} = {}; # first field in subject file 
     99    $self->{'locatorlist'} = {}; # second field in subject file 
     100    $self->{'subjectfile'} = $subjectfile; 
     101    $self->{'metaname'} = $metadata; 
     102    $self->{'sortname'} = $sortname; 
     103    $self->{'title'} = $title; 
     104     
     105    return bless $self, $class; 
    96106} 
    97107 
  • trunk/gsdl/perllib/classify/List.pm

    r1086 r1483  
    4242use sorttools; 
    4343 
     44sub BEGIN { 
     45    @ISA = ('BasClas'); 
     46} 
     47 
    4448sub new { 
    4549    my ($class, @options) = @_; 
     50    my $self = new BasClas ($class, @_); 
    4651 
    4752    my $list = []; 
     
    7378    } 
    7479 
    75     return bless { 
    76     'list'=>$list, 
    77     'metaname' => $metaname, 
    78     'title' => $title, 
    79     'sortname' => $sortname 
    80     }, $class; 
     80    $self->{'list'} = $list; 
     81    $self->{'metaname'} = $metaname; 
     82    $self->{'title'} = $title; 
     83    $self->{'sortname'} = $sortname; 
     84 
     85    return bless $self, $class; 
    8186} 
    8287 
     
    119124        if (defined $metavalue) { 
    120125        if (defined $self->{'list'}->{$doc_OID}) { 
    121             print STDERR "WARNING: List::classify called multiple times for $doc_OID\n"; 
     126            my $outhandle = $self->{'outhandle'}; 
     127            print $outhandle "WARNING: List::classify called multiple times for $doc_OID\n"; 
    122128        }  
    123129        $self->{'list'}->{$doc_OID} = $sortmeta; 
     
    125131    } else { 
    126132        if (defined $self->{'list'}->{$doc_OID}) { 
    127         print STDERR "WARNING: List::classify called multiple times for $doc_OID\n"; 
     133        my $outhandle = $self->{'outhandle'}; 
     134        print $outhandle "WARNING: List::classify called multiple times for $doc_OID\n"; 
    128135        }  
    129136        $self->{'list'}->{$doc_OID} = $sortmeta; 
  • trunk/gsdl/perllib/classify/SectionList.pm

    r1362 r1483  
    3030package SectionList; 
    3131 
     32use List; 
    3233use sorttools; 
    3334 
    3435sub BEGIN { 
    3536    @ISA = ('List'); 
     37} 
     38 
     39sub new { 
     40    my ($class, @options) = @_; 
     41    my $self = new List ($class, @_); 
    3642} 
    3743 
     
    94100        if (defined $metavalue) { 
    95101        if (defined $self->{'list'}->{"$doc_OID.$section"}) { 
    96             print STDERR "WARNING: SectionList::classify called multiple times for $doc_OID.$section\n"; 
     102            my $outhandle = $self->{'outhandle'}; 
     103            print $outhandle "WARNING: SectionList::classify called multiple times for $doc_OID.$section\n"; 
    97104        }  
    98105        $self->{'list'}->{"$doc_OID.$section"} = $sortmeta; 
     
    100107    } else { 
    101108        if (defined $self->{'list'}->{"$doc_OID.$section"}) { 
    102         print STDERR "WARNING: SectionList::classify called multiple times for $doc_OID.$section\n"; 
     109        my $outhandle = $self->{'outhandle'}; 
     110        print $outhandle "WARNING: SectionList::classify called multiple times for $doc_OID.$section\n"; 
    103111        }  
    104112        $self->{'list'}->{"$doc_OID.$section"} = $sortmeta; 
  • trunk/gsdl/perllib/mgbuilder.pm

    r1424 r1483  
    128128     
    129129    # load all the classifiers 
    130     $self->{'classifiers'} = &classify::load_classifiers ($classifiers); 
     130    $self->{'classifiers'} = &classify::load_classifiers ($classifiers, $outhandle); 
    131131 
    132132    # load up any dontgdbm fields