Ignore:
Timestamp:
2004-12-15T14:10:41+13:00 (19 years ago)
Author:
mdewsnip
Message:

Updated files for Kea 3.0, thanks to Olena.

File:
1 edited

Legend:

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

    r8789 r8814  
    9696    'desc' => "{BasPlug.markup_acronyms}",
    9797    'type' => "flag",
    98     'reqd' => "no" },
     98    'reqd' => "no" }, 
    9999      { 'name' => "extract_keyphrases",
    100100    'desc' => "{BasPlug.extract_keyphrases}",
    101101    'type' => "flag",
    102     'reqd' => "no" }, 
     102    'reqd' => "no" },
    103103      { 'name' => "extract_keyphrase_options",
    104104    'desc' => "{BasPlug.extract_keyphrase_options}",
    105105    'type' => "string",
    106106    'deft' => "",
    107     'reqd' => "no" }, 
     107    'reqd' => "no" },
    108108      { 'name' => "first",
    109109    'desc' => "{BasPlug.first}",
     
    872872
    873873
    874 #adding kea keyphrases
     874    # adding kea keyphrases
     875
    875876    if ($self->{'kea'}) { 
    876877   
     
    879880    my @list;
    880881
    881     while (defined $thissection) { #loop through sections to gather whole doc
     882    #loop through sections to gather whole doc
     883    while (defined $thissection) {
    882884        my $sectiontext = $doc_obj->get_text($thissection);   
    883885        $text = $text.$sectiontext;
     
    885887    }
    886888       
    887     #if kea options flag is set, call Kea with specified options
     889
    888890    if($self->{'kea_options'}) {
    889         @list = &Kea::extract_KeyPhrases ($text, $self->{'kea_options'});
    890     }
    891     #otherwise call Kea with no options
    892     else {
    893         @list = &Kea::extract_KeyPhrases ($text);
    894     }
    895      
    896     if(@list){ #if a list of kea keyphrases was returned (ie not empty)
    897         my $keyphrases = $list[0]; #first arg is keyphrase list
    898         my $stems = $list[1]; #second  arg is stemmed keyphrase list
    899         &gsprintf(STDERR, "{BasPlug.keyphrases}: $keyphrases\n");
    900         # print STDERR "keyphrases: $keyphrases\n";
    901         &gsprintf(STDERR, "{BasPlug.stems}: $stems\n");
    902         # print STDERR "stems: $stems\n";
    903         $thissection = $doc_obj->get_top_section(); #add metadata to top section
     891        #if kea options flag is set, call Kea with specified options
     892        $list = &Kea::extract_KeyPhrases ($text, $self->{'kea_options'});
     893    } else {
     894        #otherwise call Kea with no options
     895        $list = &Kea::extract_KeyPhrases ($text);
     896    }
     897    if($list){
     898        # if a list of kea keyphrases was returned (ie not empty)
     899        &gsprintf(STDERR, "{BasPlug.keyphrases}: $list\n");
     900
     901        #add metadata to top section
     902        $thissection = $doc_obj->get_top_section();
     903
    904904        # add all key phrases as one metadata
    905         $doc_obj->add_metadata($thissection, "Keyphrases", $keyphrases);
     905        $doc_obj->add_metadata($thissection, "Keyphrases", $list);
     906
    906907        # add individual key phrases as multiple metadata
    907         foreach my $keyphrase (split(',', $keyphrases)) {
    908             $keyphrase =~ s/^\s*//; $keyphrase =~ s/\s*$//;
     908        foreach my $keyphrase (split(',', $list)) {
     909            $keyphrase =~ s/^\s+|\s+$//g;
    909910        $doc_obj->add_metadata($thissection, "Keyphrase", $keyphrase);
    910911        }
    911         $doc_obj->add_metadata($thissection, "stems", $stems);
    912     }
    913     } #end of kea
     912    }
     913    }
     914 
     915    #end of kea
    914916
    915917    if ($self->{'first'}) {
Note: See TracChangeset for help on using the changeset viewer.