Yandex::Translate - a simple API for Yandex.Translate
version 1.002
use Yandex::Dictionary; use Data::Dumper; use utf8; my $dic = Yandex::Dictionary->new; $dic->set_key('yandex_key'); $dic->set_text('time'); $dic->set_lang('en-ru'); my @result = $dic->get_result(); print Dumper \@result ,"\n";
The API is used for getting detailed dictionary entries from the static Yandex.Dictionary. Unlike conventional translation dictionaries, it is compiled automatically using the technologies at the root of the Yandex machine translation system. Yandex.Dictionary entries include the word’s part of speech, and translations are grouped with examples. For English words, the transcription is provided. The service supports a total of 17 language pairs.
Note also that the “Yandex Terms of Use of API Yandex.Dictionary Service” at https://yandex.com/legal/translate_api/ must be observed.
$tr = Yandex::Dictionary->new(@attributes);
This constructor returns a new Yandex::Dictionary object. Optional attributes include:
Yandex::Dictionary
_key_ - An API key that you can get from the Yandex website after registering, string format.
_text_ - Input Text, string format.
_lang_ - pair lang eg: en-ru from english tu russian, string format.
_ui_ - The user interface language, string format.
_format_ - The returned text format, either json (default) or xml.
json
xml
$dic->set_key('yandex_key');
This method is used to pass a Yandex API key (string), instead of passing it in "new". A Yandex::Dictionary object can be instantiated without any attributes.
$tr->set_text('input_text');
This method is used to pass a text(string).
$dic->set_lang('en-ru');
This method is used to pass a pair lang (string). For example, english would be given as en and russian would be given as ru.
en
ru
$dic->set_ui('fr');
This method is used to set the user interface language (string). For example, French would be given as fr.
fr
$dic->set_default_ui('ru');
This method is used to set the default user interface language (string). Either ru (Russian) or en (English) or tr (Turkish) can be given.
tr
$dic->set_format('json');
This method is used to set the format of the output (string). Either json or xml can be given.
my $output = $dic->get_result(); print $output , "\n";
This method is used to get the output result. If "set_format" is 'json' It returns json result that you can parse by yourself, if "set_format" is 'xml' It returns xml result that you can parse by yourself, check examples/result.json.
my $output = $dic->get_langs_list(); print $output , "\n";
This method is used to get the list of supported translation directions. It returns json result that you can parse by yourself, if "set_format" is 'xml' it returns xml result that you can parse by yourself.
print join(',', $dic->james_axl_langs_list()), "\n"; print scalar($dic->james_axl_langs_list()), "\n";
This method is used to get the list of supported translation directions. In array context, it returns an array of these directions; in scalar context, it returns the count of them.
my @result = $dic->get_input_text_pos_ts(); print Dumper \@result;
This method is used to get the input text that you enter, pos (Part of speech) and ts.
my @result = $dic->get_result_tr_pos_gen(); print Dumper \@result;
This method is used to get the text translate, pos and gen(genre).
my @result = $dic->get_result_mean() print Dumper \@result;
This method is used to get the list of meaning of the input text.
my @result = $dic->get_result_syn; print Dumper \@result;
This method is used to get the list of synonyms.
my @result = $dic->get_result_eg; print Dumper \@result;
This method is used to get the list of examples with translate.
For more information, please visit Yandex.
Please report any bugs or feature requests on my email.
https://fossil.falseking.site/ticket
This is open source software. The code repository is available for public review and contribution under the terms of the license.
https://fossil.falseking.site/dir?ci=tip&type=tree
James Axl <axlrose112@gmail.com>
<axlrose112@gmail.com>
Christian Carey
This software is copyleft © 2017 by James Axl.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Yandex::Translate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Yandex::Translate
CPAN shell
perl -MCPAN -e shell install Yandex::Translate
For more information on module installation, please visit the detailed CPAN module installation guide.