pimp: Improve Texts via Round-Trip Translation with the DeepL API...

View source: R/pimp.R

pimpR Documentation

Improve Texts via Round-Trip Translation with the DeepL API Pro

Description

pimp translates a text into a helper language and then back to the original language using the DeepL API Pro. This method can be used to refine or rephrase text automatically.

Usage

pimp(text, source_lang, help_lang, auth_key)

Arguments

text

A character vector containing the texts to be improved. Only UTF-8 encoded plain text is supported. Each element may contain multiple sentences but should not exceed 30 kB.

source_lang

A string specifying the source language of the input text. If of length 1, the same language is applied to all elements.

help_lang

A string specifying the helper language used for the intermediate translation.

auth_key

A string representing the authentication key for the DeepL API Pro. If not provided, the function will attempt to retrieve the key from the environment variable DEEPL_API_KEY. You can set this variable using Sys.setenv(DEEPL_API_KEY = "your_key") or define it in your .Renviron file for persistent use.

Details

To use this function, you must obtain an authentication key by registering for a DeepL API Pro account at DeepL API Pro. This service may incur costs based on the number of translated characters. To view all supported languages, use available_languages.

References

DeepL API Documentation on Translation

Examples

## Not run: 
pimp(
  "In former times I lived in Zurich", 
  source_lang = "EN", 
  help_lang = "DE"
  )

## End(Not run)


deeplr documentation built on June 8, 2025, 12:47 p.m.