Aldebaran has asked for the wisdom of the Perl Monks concerning the following question:
I have to divide my life into things that I can change and those I can't, and I wasn't prepared for how quickly I would need to look for google alternatives when they alleged I was a computer and locked me out of my account. I had to realize how dished out to them I truly am. I did not choose for this to be the year I would have to talk about Google, and would be embarrassed for others to know how much this feels like a divorce or jilted lover saga. Google and I: we had some good times, but we've grown apart. Having to switch from my familiar android just takes my breathe away, but I'll come out the other side. So, I'll go with apple until they have some outrageous untenability, and so it goes with the corporate goliaths: pick your poison and exposure.
I rely on google heavily in translation scripts and tried to work up a reasonably-sized SSCCE for it. This script worked better before it worked worse, but it should suffice as a starting point:
#!/usr/bin/perl use v5.030; # strictness implied use warnings; use Path::Tiny; my $file_in = path("/home/fritz/Desktop/1.enchanto.txt"); my $file_out = path('/home/fritz/Desktop/1.enc_trans.txt'); my $lang = 'es'; my $command = 'trans -b :$lang "$para">$buffer'; my $guts = $file_in->slurp_utf8; my @spl = split('\n', $guts); say @spl; my $buffer; for my $para (@spl){ say $para; my $trans = system("$command"); say $buffer; #$file_out->spew_utf8( $para, $trans ); } __END__
What I typically do is use perl to wrap the trans call from the soimort translate shell on github. I'm not wild about this dependency anymore, and the resulting calling code is hideous, but it has been reliable in at least this form:
foreach (@matching2) { my $eng_path = path( $vars{eng_captions}, $_ ); say $fh "##$_##"; my $rus_path = path( $vars{rus_captions}, $_ )->touchpath; say "rus_path is $rus_path"; my $content = path($eng_path)->slurp_utf8; $content =~ s/^\s+|\s+$//g; say $fh "$content"; system("trans :$lang file://$eng_path >$rus_path"); }
I'd like to get away both from this trans package and google, so I'm wondering what else is out there. I think this answer has changed over the last year or so with the balkanization of the internet. For example, in the following snippet, I think the bing one succeeds and the yandex has failed (from my perspective), and this, as I say, over the course of the last year:
print "Get other translations(y/n)?: "; my $prompt = <STDIN>; chomp $prompt; if ( $prompt eq ( "y" or "Y" ) ) { my @translators = qw /yandex bing/; for my $remote (@translators) { my $trans_munge = path( $vars{translations}, "$remote." . $munge + ); ## use trans shell say "getting translation from $remote"; system("trans :$lang -e $remote file://$in_path >$trans_munge"); }
So let me ask the question like this, given that I want to get away from the trans package and google, what options do I have for machine translations with perl?
Thanks for your comment,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: De-googleizing translation scripts
by kikuchiyo (Hermit) on Nov 05, 2022 at 22:07 UTC | |
by Aldebaran (Curate) on Nov 06, 2022 at 04:54 UTC | |
by bliako (Abbot) on Nov 06, 2022 at 09:06 UTC | |
by 1nickt (Canon) on Nov 06, 2022 at 12:55 UTC | |
by bliako (Abbot) on Nov 06, 2022 at 16:18 UTC | |
by Aldebaran (Curate) on Nov 07, 2022 at 06:59 UTC | |
by bliako (Abbot) on Nov 07, 2022 at 10:26 UTC | |
| |
by karlgoethebier (Abbot) on Nov 06, 2022 at 13:13 UTC | |
by karlgoethebier (Abbot) on Nov 07, 2022 at 01:28 UTC | |
by hv (Prior) on Nov 07, 2022 at 14:36 UTC | |
by karlgoethebier (Abbot) on Nov 07, 2022 at 19:36 UTC | |
|
Re: De-googleizing translation scripts
by Bod (Parson) on Nov 05, 2022 at 11:55 UTC |