Ignore:
Timestamp:
2000-08-11T11:12:15+12:00 (24 years ago)
Author:
say1
Message:

acronym markup functionality

File:
1 edited

Legend:

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

    r1384 r1393  
    6767    print STDERR "                     file extensions.\n";
    6868    print STDERR "   -extract_acronyms Extract acronyms from within text and set as metadata\n\n";
     69    print STDERR "   -markup_acronyms  Added acronym metadata into document text\n\n";
    6970    print STDERR "   -extract_langauge Identify the language of the text and set as metadata\n\n";
    7071}
     
    9091             q^block_exp/.*/^, \$self->{'block_exp'},
    9192             q^extract_acronyms^, \$self->{'extract_acronyms'},
     93             q^markup_acronyms^, \$self->{'markup_acronyms'},
    9294             q^extract_language^, \$self->{'extract_language'},
    9395             "allow_extra_options")) {
     
    297299    }
    298300
     301    if ($self->{'markup_acronyms'}) {
     302    my $thissection = $doc_obj->get_top_section();
     303    while (defined $thissection) {
     304        my $text = $doc_obj->get_text($thissection);
     305        $text = $self->markup_acronyms ($text, $doc_obj, $thissection);
     306        $doc_obj->delete_text($thissection);
     307        $doc_obj->add_text($thissection, $text);
     308        $thissection = $doc_obj->get_next_section ($thissection);
     309    }
     310    }
     311
    299312    if ($self->{'extract_language'}) {
    300313    my $thissection = $doc_obj->get_top_section();
     
    341354    my ($textref, $doc_obj, $thissection) = @_;
    342355
    343     print STDERR " checking for acronyms ...\n"
     356    print STDERR " extracting acronyms ...\n"
    344357    if ($self->{'verbosity'} >= 2);
    345358
     
    362375    if ($seen_before eq "false")
    363376    {
     377        #write it to the file ...
     378        $acro->write_to_file();
     379
    364380        #do the normal acronym
    365381        $doc_obj->add_utf8_metadata($thissection, "Acronym",  $acro->to_string());
     
    367383            if ($self->{'verbosity'} >= 1);
    368384       
    369         # do the KWIC (Key Word In Context) acronym
    370         my @kwic = $acro->to_string_kwic();
    371         foreach my $kwic (@kwic) {
    372         $doc_obj->add_utf8_metadata($thissection, "AcronymKWIC",  $kwic);
    373         print STDERR "   adding ".  $kwic . "\n"
    374             if ($self->{'verbosity'} >= 2);
    375         }
    376     }
    377     }
    378     print STDERR " done with acronyms. \n"
     385#       # do the KWIC (Key Word In Context) acronym
     386#       my @kwic = $acro->to_string_kwic();
     387#       foreach my $kwic (@kwic) {
     388#       $doc_obj->add_utf8_metadata($thissection, "AcronymKWIC",  $kwic);
     389#       print STDERR "   adding ".  $kwic . "\n"
     390#           if ($self->{'verbosity'} >= 2);
     391#       }
     392    }
     393    }
     394    print STDERR " done extracting acronyms. \n"
    379395    if ($self->{'verbosity'} >= 2);
    380396}
    381397
     398sub markup_acronyms {
     399    my $self = shift (@_);
     400    my ($text, $doc_obj, $thissection) = @_;
     401
     402    print STDERR " marking up acronyms ...\n"
     403    if ($self->{'verbosity'} >= 2);
     404
     405    #self is passed in to check for verbosity ...
     406    $text = &acronym::markup_acronyms($text, $self);
     407
     408    print STDERR " done marking up acronyms. \n"
     409    if ($self->{'verbosity'} >= 2);
     410
     411    return $text;
     412}
     413
    3824141;
Note: See TracChangeset for help on using the changeset viewer.