Перевод содержимого/Машинный Перевод/MT Клиенты

This page is a translated version of the page Content translation/Machine Translation/MT Clients and the translation is 45% complete.

В рамках модуля Перевода содержимого страниц доступ к сервисам машинного перевода осуществляется с помощью клиентских модулей. У нас уже есть клиенты для Apertium и Yandex, реализованные в коде. Можно добавить любое количество таких клиентов для служб машинного перевода и сопоставить их с языковыми парами. Эта документация объясняет архитектуру машинного клиента.

Технические требования

Communication diagram of MT Client

A new MT client can be a locally hosted machine translation system or a remote machine translation system accessed through API. API based services are recommended since that allows to isolate it as a service. If the client is free licensed and better packaged for Linux distros, we can consider hosting it in Wikimedia cluster. For example, Apertium is hosted inside wmflabs. On the other hand, Yandex is not hosted by Wikimedia. Both apertium and yandex are accessed using the web APIs.

API перевода

A machine translation API takes source language, target language, source content and outputs translated content.

  • If API is not public, it can accept an authentication token, mostly a key.
  • The output format can be JSON for convenience.
  • API shoud accept POST.
  • API should not demand any user identifiable information such as user name. CXServer does not provide it to MT Client.
  • API should be capable of accepting a reasonable number of requests per minute.
  • API should accept a reasonable amount of content per request.
  • It is recommended to have a dashboard to analyse the usage of API including requests per day/week/month and Number of characters translated per day/week/month

API must be publicly documented including the error codes.

Руководящие принципы работы

Перевод содержимого по-прежнему является бета-версией, доступной только для зарегистрированных участников. Таким образом, текущая модель использования может оказаться неправильной оценкой для будущего. Более того, когда мы расширим машинный перевод на большее количество языков, будет больше пользователей и запросов. Ниже приведены некоторые исходные данные на базе нашего текущего режима использования этого функционала. Обратите внимание, что это никогда не будет окончательной оценкой. Программные интерфейсы (API) должны быть разработаны таким образом, чтобы принимать больше, чем здесь указано.

  • Не менее 10 000 запросов в день
  • Не менее 10 миллионов символов в день
  • Не менее 5000 символов в запросе

Входной формат

The content to translate from CX is HTML formatted. Translating HTML while preserving markup is challenging, but some MT Engines are capable of that (example: Yandex). Apertium does not handle HTML markup. Depending on the capability, CX can send plain text version or HTML of the content.

Качество перевода

We evaluate the quality of MT by requesting feedback from Wikipedia contributors from the language in context. CX uses MT as an intial translation template and encourage translators to improve it. Because of that unless the quality is quite bad as per the feedback we get, we can use it.

Разработка нового клиентского модуля машинного перевода

The best way to learn this is to refer an existing client module like Yandex or Apertium. The client modules are present in cxserver's lib/mt folder. Let us call our client as BabelFish MT Client. Create a file named BabelFish.js in lib/mt folder.

const MTClient  = require( './MTClient.js' );

<!--T:33-->
// Class constructor
class BabelFish extends MTClient {
    /**
     * Translate content with BabelFish
     *
     * @param {string} sourceLang Source language code
     * @param {string} targetLang Target language code
     * @param {string} content Source language content
     * @return {Promise} Translated text
     */
    translate( sourceLang, targetLang, content ) {
        // Add your API request to the service. return a Promise object.
    }
}
module.exports = BabelFish;

If your BabelFish service is not capable of translating HTML by retaining all markup in appropriate position in translation, instead of translate, you will have to write translateText method in the above code. Refer Apertium.js for such an example. Yandex.js is an example for MT client that is capable of handling both html and text content.

You need to add an entry in lib/mt/index.js for your new client.

To map a language pair to use this client, create a config file in config folder. You may refer exiting configuration files for examples. Then enable this MT engine in the cxserver config.yaml. Here also follow the existing entries for examples.

Restart the cxserver and test your client. You may want to read some unit tests existing for Apertium to write your own tests.

Клиенты для сервисов машинного перевода =

The following are machine translation clients that support Content Translation in different languages: