Oy, I knew something was up when the character went unicode in the c tags. Thank you for taking the time to point it out. I like to preserve the vertical space in my threads for replies, so will put new code, comments, and questions in readmore tags:
I didn't want to begin with that ridiculous keystroke error, but tja. The current options with defaults are worth a reading:
module-starter [options] Options: --module=module Module name (required, repeatable) --distro=name Distribution name (optional) --dir=dirname Directory name to create new module in (optio +nal) --builder=module Build with 'ExtUtils::MakeMaker' or 'Module:: +Build' --eumm Same as --builder=ExtUtils::MakeMaker --mb Same as --builder=Module::Build --mi Same as --builder=Module::Install (discourage +d) --author=name Author's name (taken from getpwuid if not pro +vided) --email=email Author's email (taken from EMAIL if not provi +ded) --ignores=type Ignore type files to include (repeatable) --license=type License under which the module will be distri +buted (default is artistic2) --genlicense Generate LICENSE file according to specified +license --minperl=ver Minimum Perl version required (optional; default is 5.006) --fatalize Generate code that causes all warnings to be +fatal with: use warnings FATAL => 'all' --verbose Print progress messages while working --force Delete pre-existing files if needed --help Show this message $
I created it in the following directory with the following command:
$ pwd /home/bob/Documents/meditations/castaways $ ls $ module-starter --module=translate --author="professor" --email=prof@ +island.coconut Added to MANIFEST: Changes Added to MANIFEST: ignore.txt Added to MANIFEST: lib/translate.pm Added to MANIFEST: Makefile.PL Added to MANIFEST: MANIFEST Added to MANIFEST: README Added to MANIFEST: t/00-load.t Added to MANIFEST: t/manifest.t Added to MANIFEST: t/pod-coverage.t Added to MANIFEST: t/pod.t Added to MANIFEST: xt/boilerplate.t Created starter directories and files $ ls translate $ cd translate/ $ ls Changes ignore.txt lib Makefile.PL MANIFEST README t xt $
Now, what will I try to do with this software tool? I thought that an authentic task it could do is translate text. I have written scripts before that do as much. It might be nice to work up a few different ways, but I thought the first best one might be to use the google api:
#!/usr/bin/perl -w use 5.011; use WWW::Google::Translate; use Config::Tiny; use Data::Dumper; use open OUT => ':encoding(UTF-8)', ':std'; use Path::Tiny; my $ini_path = qw( /home/bob/Documents/html_template_data/3.values.ini + ); say "ini path is $ini_path"; my $tempfile = Path::Tiny->tempfile(TEMPLATE => 'trans_XXXXXX', suffix + => '.txt'); my $string_temp = $tempfile->stringify; say "save file is $string_temp"; my $sub_hash = "google"; my $Config = Config::Tiny->new; $Config = Config::Tiny->read( $ini_path, 'utf8' ); #say Dumper $Config; my $von = 'en'; my $zu = 'ru'; # -> is optional between brackets my $key = $Config->{$sub_hash}{'api_key_1'}; my $wgt = WWW::Google::Translate->new( { key => $key, default_source => $von, default_target => $zu, } ); my $r = $wgt->translate( { q => 'I wave my private parts at your aunti +es, you cheesy lot of second hand electric donkey-bottom biters.' } ) +; my $result = ""; for my $trans_rh ( @{ $r->{data}->{translations} } ) { $result = $trans_rh->{translatedText}; print $trans_rh->{translatedText}, "\n"; } say Dumper $r; my $wgt2 = WWW::Google::Translate->new( { key => $key, default_source => $zu, default_target => $von, cache_file => $string_temp, } ); my $s = $wgt2->translate( { q => $result} ); for my $trans_rh ( @{ $s->{data}->{translations} } ) { print $trans_rh->{translatedText}, "\n"; } say Dumper $s; say "------";
This doesn't quite work the way I want yet, because I was trying to re-translate the output back to the original language, and I get something about magic number rather than output there. Using pre-tags here so that the cyrillic characters don't blow up. (We get that representation in the output as well.)
$ ./3.trans_www.pl
ini path is /home/bob/Documents/html_template_data/3.values.ini
save file is /tmp/trans_LMuE7M.txt
Я машу своими личными частями в твоих тетушек, ты, паршивая подержанная электрическая пила с ослиным дном.
$VAR1 = {
'data' => {
'translations' =>
{
'translatedText' => "\x{42f} \x{43c}\x{430}\x{448}\x{443} \x{441}\x{432}\x{43e}\x{438}\x{43c}\x{438} \x{43b}\x{438}\x{447}\x{43d}\x{44b}\x{43c}\x{438} \x{447}\x{430}\x{441}\x{442}\x{44f}\x{43c}\x{438} \x{432} \x{442}\x{432}\x{43e}\x{438}\x{445} \x{442}\x{435}\x{442}\x{443}\x{448}\x{435}\x{43a}, \x{442}\x{44b}, \x{43f}\x{430}\x{440}\x{448}\x{438}\x{432}\x{430}\x{44f} \x{43f}\x{43e}\x{434}\x{435}\x{440}\x{436}\x{430}\x{43d}\x{43d}\x{430}\x{44f} \x{44d}\x{43b}\x{435}\x{43a}\x{442}\x{440}\x{438}\x{447}\x{435}\x{441}\x{43a}\x{430}\x{44f} \x{43f}\x{438}\x{43b}\x{430} \x{441} \x{43e}\x{441}\x{43b}\x{438}\x{43d}\x{44b}\x{43c} \x{434}\x{43d}\x{43e}\x{43c}."
}
}
};
Magic number checking on storable file failed at /usr/local/lib/x86_64-linux-gnu/perl/5.26.1/Storable.pm line 414, at /usr/local/share/perl/5.26.1/WWW/Google/Translate.pm line 82.
$
Alright, so now I've shown a little code and some output. Let me state that a reasonable test of the efficacy of this software could be that the output be within a certain range of unicode. If something is capitalized in the input and does not translate, I could take a swipe at making the usual orthographic transformations for proper names. I might consider it a pass if 75 percent of it or more gets turned to cyrillic characters.
Where should I put input files? Output files?
How do I turn a script into a package?
Thanks for your comment,
In reply to Re^2: installing module starter
by Aldebaran
in thread installing module starter
by Aldebaran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |