Ignore:
Timestamp:
2000-08-02T23:38:07+12:00 (24 years ago)
Author:
say1
Message:

many acronym changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/BasPlug.pm

    r1317 r1335  
    330330}
    331331
     332# extract acronyms from a section in a document. progress is
     333# reported to STDERR based on the verbosity. both the Acronym
     334# and the AcronymKWIC metadata items are created.
     335
    332336sub extract_acronyms {
    333337    my $self = shift (@_);
    334338    my ($textref, $doc_obj, $thissection) = @_;
    335339
     340    print STDERR " checking for acronyms ...\n"
     341    if ($self->{'verbosity'} >= 2);
     342
    336343    my $acro_array =  &acronym::acronyms($textref);
    337344
    338345    foreach my $acro (@$acro_array) {
    339346
    340     #do the normal acronym
    341     $doc_obj->add_utf8_metadata($thissection, "Acronym",  $acro->to_string());
    342     print "found " . $acro->to_string() . "\n";
    343        
    344     # do the KWIC (Key Word In Context) acronym
    345     my @kwic = $acro->to_string_kwic();
    346     foreach my $kwic (@kwic) {
    347         $doc_obj->add_utf8_metadata($thissection, "AcronymKWIC",  $kwic);
    348         print "found (KWIC)" . $kwic . "\n";
    349     }
    350     }
     347    #check that this is the first time ...
     348    my $seen_before = "false";
     349    my $previous_data = $doc_obj->get_metadata($thissection, "Acronym");
     350    foreach my $thisAcro (@$previous_data) {
     351        if ($thisAcro eq $acro->to_string())
     352        {
     353        $seen_before = "true";
     354        print STDERR "  not adding ". $acro->to_string() . "\n"
     355            if ($self->{'verbosity'} >= 2);
     356        }       
     357    }
     358
     359    if ($seen_before eq "false")
     360    {
     361        #do the normal acronym
     362        $doc_obj->add_utf8_metadata($thissection, "Acronym",  $acro->to_string());
     363        print STDERR "  adding ". $acro->to_string() . "\n"
     364            if ($self->{'verbosity'} >= 1);
     365       
     366        # do the KWIC (Key Word In Context) acronym
     367        my @kwic = $acro->to_string_kwic();
     368        foreach my $kwic (@kwic) {
     369        $doc_obj->add_utf8_metadata($thissection, "AcronymKWIC",  $kwic);
     370        print STDERR "   adding ".  $kwic . "\n"
     371            if ($self->{'verbosity'} >= 2);
     372        }
     373    }
     374    }
     375    print STDERR " checked for acronyms.\n"
     376    if ($self->{'verbosity'} >= 2);
    351377}
    352378
Note: See TracChangeset for help on using the changeset viewer.