R package to interface with Yandex Translate API for text translation services
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.circleci
R
man
.gitignore
DESCRIPTION
NAMESPACE
NEWS.md
README.md
yandextexttranslater.Rproj

README.md

yandextexttranslater

CircleCI

Overview

yandextexttranslater allows R users to interface with Yandex Translate API for text translation services. Use this package by following the instructions below to install the package and register for a free Yandex Translate API key.

Install

Use devtools package to install from GitHub:

library(devtools)
install_github("kpolimis/yandextexttranslater")

Register for a free Yandex Translate API key here

Usage

View all functions in yandextexttranslater

library(yandextexttranslater)
ls("package:yandextexttranslater")
[1] "load_api_key"   "yandex_detect_language"   "yandex_supported_languages"   "yandex_translate"

First, use the function's text prompt to enter and save your Yandex API key to a file called yandex_api_key.yml; this function also adds the value yandex_api_key to the global environment. You can alternatively specify a directory in the function call that contains yandex_api_key.yml and load the Yandex API key to your global environment.

load_api_key(directory="")

Yandex Translate API services

See Resources below for full API documentation

Get a list of translation directions and abbreviation-language pairs for language abbreviations supported by Yandex Translate API

supported_languages = yandex_supported_languages(yandex_api_key)
available_translations = supported_languages[[1]]
abbreviations = supported_languages[[2]]
head(available_translations)
translation from_language to_language
1       az-ru            az          ru
2       be-bg            be          bg
3       be-cs            be          cs
4       be-de            be          de
5       be-en            be          en
6       be-es            be          es
head(abbreviations)
abbreviation    language
1           af   Afrikaans
2           am     Amharic
3           ar      Arabic
4           az Azerbaijani
5           ba     Bashkir
6           be  Belarusian

To detect the language of the specified text

detected_languaged = yandex_detect_language(yandex_api_key, text="voglio mangiare cena")
detected_languaged
[1] "it"

To translate text to the specified language

translated_text = yandex_translate(yandex_api_key, text="voglio mangiare cena", lang="it-en")
translated_text
[1] "I want to eat dinner"

Resources