Skip to main content

从语言中的一些文本开始。使用一些中间语言逐步翻译它,然后再翻译回你开始使用的语言。看看原文是如何变化的。

项目描述

有没有想过当您尝试将某种语言的某些文本翻译成各种中间语言并返回到原始语言时会发生什么?当您从您选择的语言和文本开始(通常是 smae 语言)并将文本翻译成一系列语言,将先前的结果提供给下一个时,您最终会得到通常看起来不像原始文本的东西.

如果这没有什么意义,但这里有一个例子。

示例(使用 Yandex 的 API)

给定要遵循的步骤:['fr', 'uk', 'it', 'ru', 'pl', 'be', 'de', 'es'] 感兴趣的语言是 'en'。

'en' 开头的文字:“语言是一个自由创造的过程;它的规律和原则是固定的,但使用生成原则的方式是自由的和无限变化的。甚至文字的解释和使用也涉及到一个自由创造的过程。”

'en' 到 'fr':“La langue est un processus de création libre; ses lois et ses principes sont fix, mais la manière dont les principes de génération sont utilisés est gratuit et infiniment variés。Même l'interprétation et de l'utilisation de mots implique un processus de création libre。”

'fr' 到 'uk':“Мова-це процес вільного творчості; його закони і принципи є фіксованими, але іяк принципи побудови, використовуються безкоштовнтно, інескінченно різноманно Навіть інтерпретація і використання слова передбачає процес створення безкоштовно。

……

最后,从“es”到“en”:“这是自由创造力的过程;它的法则和原则不会改变,而是作为构建规则,它是自由的,并且是无限多样的。文字的解释和使用,意味着创造的过程是免费的。”

有关更多详细信息,请参阅使用部分。

用法

使用 pip 安装

$ pip install ulit
...

您可以将 ulit 与 Google translate API 或 Yandex translate API 一起使用

translate = ulit.Ulit("yandex", "YOUR YANDEX TRANSLATE API KEY HERE", loglevel="DEBUG")
...
translate = ulit.Ulit("yandex", "YOUR YANDEX TRANSLATE API KEY HERE", loglevel="DEBUG")
...

Yandex

import ulit

cascade_steps = ['fr', 'uk', 'it', 'ru', 'pl', 'be', 'de', 'es']
initial_language = "en"
text = "Language is a process of free creation; its laws and principles are fixed, but the manner in which the principles of generation are used is free and infinitely varied. Even the interpretation and use of words involves a process of free creation."
translate = ulit.Ulit("yandex", "YOUR YANDEX TRANSLATE API KEY HERE", loglevel="DEBUG")

all_translations_steps, final_translation = translate.service.translate_cascade(initial_language=initial_language,
                                                                                 cascade_steps=cascade_steps,
                                                                                 text=text)



# Output: all_translations_steps

{
    'pl': 'Mowa jest procesem wolnego kreatywności; jego prawa i zasady są niezmienne, ale, jak i zasady budowy, są za darmo, i nieskończenie zróżnicowana. Również interpretacja i wykorzystanie słowa oznacza proces tworzenia za darmo.',
    'it': "Il discorso è un processo di libera creatività; le sue leggi e i principi sono fissi, ma come principi di costruzione, sono utilizzati gratuitamente, e infinitamente vario. Anche l'interpretazione e l'uso della parola implica il processo di creazione di gratis.",
    'ru': 'Речь-это процесс свободного творчества; его законы и принципы неизменны, но, как и принципы строительства, используются бесплатно, и бесконечно разнообразен. Также интерпретация и использование слова подразумевает процесс создания бесплатно.',
    'de': 'Es ist der Prozess, der freien Kreativität; seine Gesetze und Prinzipien nicht ändern, aber, wie die Regeln der Bau -, Sie sind kostenlos, und es ist unendlich vielfältig. Auch die Interpretation und die Verwendung des Wortes bedeutet, den Prozess der Erstellung kostenlos.',
    'fr': "La langue est un processus de création libre; ses lois et ses principes sont fixes, mais la manière dont les principes de génération sont utilisés est gratuit et infiniment variés. Même l'interprétation et de l'utilisation de mots implique un processus de création libre.",
    'uk': 'Мова-це процес вільного творчості; його закони і принципи є фіксованими, але і як принципи побудови, використовуються безкоштовно, і нескінченно різноманітні. Навіть інтерпретація і використання слова передбачає процес створення безкоштовно.',
    'es': 'Es el Proceso, de la libre Creatividad; sus Leyes y Principios no cambian, pero, como las Reglas De la Construcción, que es gratuita, y es infinitamente diversa. La Interpretación y el Uso de la Palabra significa que el Proceso de Creación de forma gratuita.',
    'be': 'Гаворка-гэта працэс свабоднага творчасці; яго законы і прынцыпы нязменныя, але, як і правілы будаўніцтва, яны бясплатна, і бясконца разнастайны. Таксама інтэрпрэтацыя і выкарыстанне слова азначае працэс стварэння бясплатна.',
    'en': 'It is the Process, of free Creativity; its Laws and Principles do not change, but, as the Rules Of Construction, which is free, and is infinitely diverse. The Interpretation and Use of the Word means that the Process of Creating free of charge.'
}


# Output: final_translation

It is the Process, of free Creativity; its Laws and Principles do not change, but, as the Rules Of Construction, which is free, and is infinitely diverse. The Interpretation and Use of the Word means that the Process of Creating free of charge.

...

谷歌

import ulit

cascade_steps = ['fr', 'uk', 'it', 'ru', 'pl', 'be', 'de', 'es']
initial_language = "en"
text = "Language is a process of free creation; its laws and principles are fixed, but the manner in which the principles of generation are used is free and infinitely varied. Even the interpretation and use of words involves a process of free creation."
translate = ulit.Ulit("google", "YOUR YANDEX TRANSLATE API KEY HERE", loglevel="DEBUG")

all_translations_steps, final_translation = translate.service.translate_cascade(initial_language=initial_language,
                                                                                 cascade_steps=cascade_steps,
                                                                                 text=text)



# Output: all_translations_steps

{
'de': 'Sprache des Prozesses der freien Schöpfung; ihre Gesetze und Grundsätze festgelegt sind, aber das Prinzip der Produktionsweise frei. Auch die Interpretation und Verwendung von Wörtern findet ein Prozess der freien Schöpfung.',
'en': 'Language of the process of free creation; its laws and principles are fixed, but the principle of free production. The interpretation and use of words involves a process of free creation.',
'fr': 'La langue est un processus de création libre; ses lois et ses principes sont fixés, mais la manière dont les principes de la production sont utilisées est libre et infiniment varié. Même l'interprétation et de l'utilisation de mots implique un processus de création libre.',
'es': 'Idioma del proceso de creación libre; sus leyes y principios son fijos, pero el principio de producción libre. La interpretación y el uso de las palabras implica un proceso de creación libre.',
'ru': 'Язык процесс свободного создания; его законы и принципы закреплены, но принципы метода производства свободно и бесконечно разнообразны. Даже интерпретация и использование слов включает в себя процесс свободного создания.',
'uk': 'Мова процес вільного створення; його закони і принципи закріплені, але спосіб принципи виробництва використовуються вільно і нескінченно різноманітні. Навіть інтерпретація і використання слів включає в себе процес вільного створення.',
'it': 'Processo Lingua di libera creazione; le sue leggi e principi sono fissi, ma i principi del metodo di produzione utilizzati liberamente e infinitamente vario. Anche l'interpretazione e l'uso delle parole comporta un processo di creazione libera.',
'be': 'Мова працэс свабоднага стварэння; яго законы і прынцыпы замацаваныя, але прынцып спосабу вытворчасці свабодна і плаўна. Нават інтэрпрэтацыя і выкарыстанне слоў ўключае ў сябе працэс свабоднага стварэння.',
'pl': 'Język procesie utworzenia wolnego; jej prawa i zasady są stałe, ale zasady metody produkcji jest darmowy i płynnie. Nawet interpretacja i stosowanie słów obejmuje proces swobodnego tworzenia.'
}


\# Output: final_translation

Language of the process of free creation; its laws and principles are fixed, but the principle of free production. The interpretation and use of words involves a process of free creation.



...

运行测试

其中大部分是常用的,但您需要使用您的 API 密钥设置环境变量 YANDEX_API_KEY。

$ export YANDEX_API_KEY=<YOUR API KEY HERE>

$ export GOOGLE_API_KEY=<YOUR API KEY HERE>

$ python setup.py test
...

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

ulit-0.2.2.tar.gz (11.2 kB 查看哈希

已上传 source