jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/351253 )
Change subject: Matxin Machine translation client ...................................................................... Matxin Machine translation client Patch originally written by Mikel Artetxe API: http://matxin.elhuyar.eus/API API doc: http://matxin.elhuyar.eus/API_doc Source code: https://github.com/matxin Change-Id: I760c830480f052de9e03e705296e354b48aa5e4b --- M config.dev.yaml M config.prod.yaml M lib/mt/MTClient.js A lib/mt/Matxin.js M lib/mt/index.js M registry.wikimedia.yaml M registry.yaml M spec.yaml 8 files changed, 50 insertions(+), 3 deletions(-) Approvals: jenkins-bot: Verified Nikerabbit: Checked; Looks good to me, approved diff --git a/config.dev.yaml b/config.dev.yaml index f171eef..918d7e1 100644 --- a/config.dev.yaml +++ b/config.dev.yaml @@ -68,4 +68,6 @@ youdao: api: https://fanyi.youdao.com/paidapi/fanyiapi key: null + matxin: + api: http://matxin.elhuyar.eus/API registry: ./registry.yaml diff --git a/config.prod.yaml b/config.prod.yaml index 362ab26..fd4c3fc 100644 --- a/config.prod.yaml +++ b/config.prod.yaml @@ -68,4 +68,6 @@ youdao: api: https://fanyi.youdao.com/paidapi/fanyiapi key: null + matxin: + api: http://matxin.elhuyar.eus/API registry: ./registry.wikimedia.yaml diff --git a/lib/mt/MTClient.js b/lib/mt/MTClient.js index 582b8e5..1190ff4 100644 --- a/lib/mt/MTClient.js +++ b/lib/mt/MTClient.js @@ -11,9 +11,11 @@ * * @class * - * @constructor + * @param {Object} options */ -function MTClient() { +function MTClient( options ) { + this.logger = options.logger; + this.conf = options.conf; this.sourceDoc = null; this.sourceHTML = null; } diff --git a/lib/mt/Matxin.js b/lib/mt/Matxin.js new file mode 100644 index 0000000..e45b102 --- /dev/null +++ b/lib/mt/Matxin.js @@ -0,0 +1,33 @@ +'use strict'; + +const preq = require( 'preq' ), + MTClient = require( './MTClient.js' ); + +/** + * Matxin machine translation service client. + * API doc: http://matxin.elhuyar.eus/API_doc + * Source code: https://github.com/matxin + */ +class Matxin extends MTClient { + /** + * Translate plain text with Matxin API + * Matxin is not capable of HTML translation with all annotation mapping. + * For translating HTML, It use CX's annotation mapping on top of the plaintext translation. + * + * @param {string} sourceLang Source language code + * @param {string} targetLang Target language code + * @param {string} sourceText Source language text + * @return {BBPromise} Promise that resolves translated text with line seperator as .॥॥. + */ + translateText( sourceLang, targetLang, sourceText ) { + return preq.post( { + uri: this.conf.mt.matxin.api, + body: { + direction: sourceLang + '-' + targetLang, + text: sourceText + } + } ).then( ( response ) => response.body.translation.replace( /\. ॥ ॥\. /g, '.॥॥.' ) ); + } +} + +module.exports = Matxin; diff --git a/lib/mt/index.js b/lib/mt/index.js index fa0406c..505fa97 100644 --- a/lib/mt/index.js +++ b/lib/mt/index.js @@ -3,5 +3,6 @@ module.exports = { Apertium: require( './Apertium.js' ), Yandex: require( './Yandex.js' ), - Youdao: require( './Youdao.js' ) + Youdao: require( './Youdao.js' ), + Matxin: require( './Matxin.js' ) }; diff --git a/registry.wikimedia.yaml b/registry.wikimedia.yaml index b37e3b9..499f7db 100644 --- a/registry.wikimedia.yaml +++ b/registry.wikimedia.yaml @@ -9181,6 +9181,9 @@ - ko - pt - ru + Matxin: + es: + - eu defaults: # source-mt : Source text as default MT option. 'en-am': source-mt diff --git a/registry.yaml b/registry.yaml index 562e1f6..d17309d 100644 --- a/registry.yaml +++ b/registry.yaml @@ -1172,6 +1172,9 @@ - zh zh: - en + Matxin: + es: + - eu dictionary: Dictd: en: diff --git a/spec.yaml b/spec.yaml index ab45835..df2f066 100644 --- a/spec.yaml +++ b/spec.yaml @@ -179,6 +179,7 @@ required: false enum: - Apertium + - Matxin - name: html in: formData description: The HTML content to translate -- To view, visit https://gerrit.wikimedia.org/r/351253 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I760c830480f052de9e03e705296e354b48aa5e4b Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/services/cxserver Gerrit-Branch: master Gerrit-Owner: Santhosh <[email protected]> Gerrit-Reviewer: Nemo bis <[email protected]> Gerrit-Reviewer: Nikerabbit <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
