AIIA-GMT
view release on metacpan or search on metacpan
lib/AIIA/GMT.pm view on Meta::CPAN
package AIIA::GMT;
use 5.008008;
use strict;
use warnings;
use Frontier::Client;
require Exporter;
use AutoLoader qw(AUTOLOAD);
our @ISA = qw(Exporter);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
# This allows declaration use AIIA::GMT ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = ( 'all' => [ qw(pmid2entity text2entity) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(pmid2entity text2entity);
our $VERSION = '0.05';
require XSLoader;
XSLoader::load('AIIA::GMT', $VERSION);
# Preloaded methods go here.
# Autoload methods go after =cut, and are processed by the autosplit program.
my $SERVER_URL = 'http://bcsp1.iis.sinica.edu.tw:8080/aiiagmt/XmlRpcServlet';
sub pmid2entity {
my $id = shift;
die "Usage: &pmid2entity(\'PubMed Article ID\');\n" if ($id !~ /^\d+$/);
return &submit($id);
}
sub text2entity {
my $txt = shift;
$txt =~ s/\n//g;
my $num;
map {$num++;} split(/\s/, $txt);
die "Usage: &text2entity(\'less than 3000 words\');\n" if ($num > 3000);
return &submit($txt);
}
sub submit {
my @args = (shift);
my $client = Frontier::Client->new(url => $SERVER_URL, debug => 0);
my $ret = $client->call('Annotator.getAnnotation', @args);
my @rep;
map {push @rep, $_->{'offset'} . "\t" . $_->{'mention'};} @{$ret->{'mentions'}};
@rep = sort @rep;
return \@rep;
}
1;
__END__
# Below is stub documentation for your module. You'd better edit it!
=head1 NAME
AIIA::GMT - a XML-RPC client of a web-service server, AIIA gene mention tagger, which provides the service to recognize named entities in the biomedical articles
=head1 SYNOPSIS
use YAML;
use AIIA::GMT;
$result = &text2entity('less than 3000 words');
( run in 1.083 second using v1.01-cache-2.11-cpan-39bf76dae61 )