Ignore:
Timestamp:
1999-08-02T17:17:27+12:00 (25 years ago)
Author:
sjboddie
Message:

changed way options are passed

File:
1 edited

Legend:

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

    r385 r426  
    11# simple list classifier plugin
    2 # collect.cfg usage: 'List metaelement' or simply 'List'
    3 # the first will create a single list of all documents
    4 # with metaelement metadata (sorted alphabetically by whichever
    5 # metadata element was chosen).
    6 # The second will create a single list of all documents
    7 # which won't be sorted at all - they may well be in
    8 # some completely random order ;-|
    9 
     2# options are:
     3# metadata=Metaname -- (optional) all documents with Metaname metadata
     4#                      will be included in list, list will be sorted
     5#                      by this element. if not included all documents
     6#                      will be included in list in build (random) order
     7# title=Title       -- (optional) the title field for this classification.
     8#                      if not included title field will be Metaname.
     9#                      if metadata is also not included title will be 'List'
    1010
    1111package List;
     
    1717
    1818    my $list = [];
    19     if (defined $options[0]) {
    20     $list = {};
     19    my ($metaname, $title);
     20
     21    foreach $option (@options) {
     22    if ($option =~ /^metadata=(.*)$/i) {
     23        $metaname = $1;
     24        $list = {};
     25    } elsif ($option =~ /^title=(.*)$/i) {
     26        $title = $1;
     27    }
     28    }
     29
     30    if (!defined $title) {
     31    if (defined $metaname) {
     32        $title = $metaname;
     33    } else {
     34        $title = 'List';
     35    }
    2136    }
    2237
    2338    return bless {
    2439    'list'=>$list,
    25     'metaname' => $options[0]
     40    'metaname' => $metaname,
     41    'title' => $title
    2642    }, $class;
    2743}
     
    5369        }
    5470        if (defined $self->{'list'}->{$doc_OID}) {
     71        print STDERR "metavalue: $metavalue\n";
     72        print STDERR "title: $self->{'title'}\n";
    5573        print STDERR "WARNING: List::classify called multiple times for $doc_OID\n";
    5674        }
     
    6583    my $self = shift (@_);
    6684
    67     my $classifytitle = "List";
    6885    my $contains = "";
    6986    my @list = ();
    7087    if (defined $self->{'metaname'}) {
    71     $classifytitle = $self->{'metaname'};
    7288    if (keys %{$self->{'list'}}) {
    7389        @list = sort {$self->{'list'}->{$a}
     
    8096    # organise into classification structure
    8197    my %classifyinfo = ('classifytype'=>'List',
    82             'Title'=>$classifytitle,
     98            'Title'=>$self->{'title'},
    8399            'contains'=>[]);
    84100    foreach $OID (@list) {
Note: See TracChangeset for help on using the changeset viewer.