Changeset 8814 for trunk/gsdl/perllib/plugins
- Timestamp:
- 2004-12-15T14:10:41+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/BasPlug.pm
r8789 r8814 96 96 'desc' => "{BasPlug.markup_acronyms}", 97 97 'type' => "flag", 98 'reqd' => "no" }, 98 'reqd' => "no" }, 99 99 { 'name' => "extract_keyphrases", 100 100 'desc' => "{BasPlug.extract_keyphrases}", 101 101 'type' => "flag", 102 'reqd' => "no" }, 102 'reqd' => "no" }, 103 103 { 'name' => "extract_keyphrase_options", 104 104 'desc' => "{BasPlug.extract_keyphrase_options}", 105 105 'type' => "string", 106 106 'deft' => "", 107 'reqd' => "no" }, 107 'reqd' => "no" }, 108 108 { 'name' => "first", 109 109 'desc' => "{BasPlug.first}", … … 872 872 873 873 874 #adding kea keyphrases 874 # adding kea keyphrases 875 875 876 if ($self->{'kea'}) { 876 877 … … 879 880 my @list; 880 881 881 while (defined $thissection) { #loop through sections to gather whole doc 882 #loop through sections to gather whole doc 883 while (defined $thissection) { 882 884 my $sectiontext = $doc_obj->get_text($thissection); 883 885 $text = $text.$sectiontext; … … 885 887 } 886 888 887 #if kea options flag is set, call Kea with specified options 889 888 890 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 904 904 # add all key phrases as one metadata 905 $doc_obj->add_metadata($thissection, "Keyphrases", $keyphrases); 905 $doc_obj->add_metadata($thissection, "Keyphrases", $list); 906 906 907 # 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; 909 910 $doc_obj->add_metadata($thissection, "Keyphrase", $keyphrase); 910 911 } 911 $doc_obj->add_metadata($thissection, "stems", $stems); 912 } 913 } #end of kea 912 } 913 } 914 915 #end of kea 914 916 915 917 if ($self->{'first'}) {
Note:
See TracChangeset
for help on using the changeset viewer.