NAME
Yandex::Dictionary - a simple API for Yandex.Dictionary
VERSION
version 0.02
SYNOPSIS
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";
DESCRIPTION
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/dictionary_api/ must be observed.
METHODS
new
$tr = Yandex::Dictionary->new(@attributes);
This constructor returns a new Yandex::Dictionary
object. Optional attributes include:
_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) orxml
.
set_key
$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.
set_text
$tr->set_text('input_text');
This method is used to pass a text(string).
set_lang
$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
.
set_ui
$dic->set_ui('fr');
This method is used to set the user interface language (string). For example, French would be given as fr
.
set_default_ui
$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.
set_format
$dic->set_format('json');
This method is used to set the format of the output (string). Either json
or xml
can be given.
get_result
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.
get_langs_list
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.
james_axl_langs_list
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.
get_input_text_pos_ts
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.
get_result_tr_pos_gen
my @result = $dic->get_result_tr_pos_gen();
print Dumper \@result;
This method is used to get the text translate, pos and gen(genre).
get_result_mean
my @result = $dic->get_result_mean()
print Dumper \@result;
This method is used to get the list of meaning of the input text.
get_result_syn
my @result = $dic->get_result_syn;
print Dumper \@result;
This method is used to get the list of synonyms.
get_result_eg
my @result = $dic->get_result_eg;
print Dumper \@result;
This method is used to get the list of examples with translate.
SEE ALSO
For more information, please visit Yandex.
SUPPORT
Bugs / Feature Requests
Please report any bugs or feature requests on my email.
https://fossil.falseking.site/ticket
Source Code
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
AUTHORS
James Axl
<axlrose112@gmail.com>
Christian Carey
COPYLEFT AND LICENSE
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.