#!/usr/bin/perl
# PODNAME: pln-pt
# ABSTRACT: command line interface to http://api.pln.pt

use warnings;
use strict;

use PLN::PT;
use Path::Tiny;

my $op = shift;

my $input;
my $file = shift;
if ($file) {
  $input = path($file)->slurp_raw;
}
else {
  $input = join('', <STDIN>);
}

unless ($input) {
  print "Usage: pln-pt <operation> <input>\n",
          "  operation: tokenizer, tagger, dep_parser\n";
  exit;
}

my $pln = PLN::PT->new('http://api.pln.pt');
my $opts = { output=>'raw' };

if (lc($op) eq 'tokenizer') {
  print $pln->tokenizer($input, $opts);
}
if (lc($op) eq 'tagger') {
  print $pln->tagger($input, $opts);
}
if (lc($op) eq 'dep_parser') {
  print $pln->dep_parser($input, $opts);
}

__END__

=pod

=encoding UTF-8

=head1 NAME

pln-pt - command line interface to http://api.pln.pt

=head1 VERSION

version 0.001

=head1 AUTHOR

Nuno Carvalho <smash@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2016 - 2017 by Nuno Carvalho.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
