Lingua::EN::Taggerでキーワードの入ったファイルをタグつけするスクリプトです。

Lingua::EN::Taggerでキーワードの入ったファイルをタグつけするスクリプトです。

use vars qw($opt_i $opt_r);
use Lingua::EN::Tagger;
use Encode;
binmode(STDOUT, ":utf8");


my $p = new Lingua::EN::Tagger;

my $dbfile   = "keywords.txt";
my $outfile = "output-pos.txt";

open (I, "$dbfile") or die "Unable to open: $dbfile";

my @lines = <I>;

close I;


@lines = reverse(@lines);

print "Welcome\nThe process will begin shortly.\n";


foreach (@lines){
		

		chomp;	
		$word = $_;	
		
		if ($word ne ""){
				open (K, ">>$outfile")   or die "Unable to open: $outfiles";
				$tagged_text = $p->add_tags($word);
				 
				print K "$word	$tagged_text\n";
				
				close K;
				}
		
		
		}