Hello Aldebaran,
haukex provided a solution to your question.
I have a suggestion regarding user interaction: Getopt::Long can parse parameters passed on to a script via the command line, i.e. the well known pattern translate.pl --from-lang XYZ --to-lang ZYX --config ABC --outfile 123 or even translate.pl --help to show available languages.
This is straight forward to implement and will help you to abstract and automate even more, for example, by creating higher level bash scripts, e.g. translate.bash "hello there" or translate.bash < /dev/telephone1 > /dev/telephone2
Here is an example
use Getopt::Long; my $outfile = undef; my $configfile = undef; my $infile = undef; if( ! Getopt::Long::GetOptions( "outfile=s", \$outfile, "infile=s", \$infile, "configfile=s", \$configfile, "help", sub { print "Usage : $0 --configfile C [--outfile O] [--infi +le I] [--help]\n"; exit 0; }, ) ){ die "error, commandline" } die "configfile is needed (via --configfile)" unless defined $configfi +le; my $inFH = <STDIN>; # read input from stdin by default, unless an in f +ile is provided if( defined $infile ){ open $inFH, '<', $infile or die "opening input +file $infile, $!"; } my $instr; {local $/ = undef; $instr = <$inFH> } if( defined ($infile){ close $inFH } # do similar for outfile and STDOUT ... # and call your module translate, input text is in $instr ...
In reply to Re: chunking up texts correctly for online translation
by bliako
in thread chunking up texts correctly for online translation
by Aldebaran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |