Send a list of wordforms to Latin lemmatizing service

Use the following script in a pipe, like this: perl persmorphb.pl wordformlistfilename > resultsfilename-json

#!/usr/bin/perl -w
# persmorphb.pl - sends a list of words to Bamboo/Morpheus morphology service
# usage: perl persmorphb.pl filename
use strict;
use warnings;
 
require LWP::UserAgent;
my $addr2 = "http://services-qa.projectbamboo.org/bsp/morphologyservice/analysis/word?lang=lat&engine=morpheus&word=";
my $verbum;
my $file = $ARGV[0];
 
open(STDIN, '<:encoding(utf8)', $file) or die "Could not open '$file' $!\n";
 
while ($verbum = <STDIN>) {
 	chomp $verbum;
 &uag();
}
sub uag {
 my $ua = LWP::UserAgent->new;
 $ua->timeout(30);
 $ua->env_proxy;
 
 my $response = 
$ua->get($addr2 . $verbum);
 
 if ($response->is_success) {
 	my $content = $response->decoded_content();
if (utf8::is_utf8($content)) {
	binmode STDOUT,':utf8';
} else {
	binmode STDOUT,':raw';
}
print $content;
#    print $response->content( );  # or whatever
     print ",\n";
 }
 else {
     die $response->status_line;
 }
}
 
z/perlmorphb.pl.txt · Last modified: 20. 01. 2013. 12:59 by njovanov
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki