Skip to content

Commit daf94f3

Browse files
authored
Regeneration of services with language translator v3 (watson-developer-cloud#719)
* feat(language translator v3): Newest generated code using generator commit 1b434 and api definitions * feat(language translator v3): adds language translator v3 file * chore(tsc compilation): fixes compilation issues by fixing generated files with handwritten changes * refactor(language translator): renames v3-generated to v3 * test(ltv3 tests): updates tests for language translator v3 * reencrypt creds * test(stt tests): skips test * 3.5.0 * docs(docs): iam url fix * docs(README): readme update for language translator v3 * docs(README): version to readme * ci(travis): makes it so only unit tests run for prs * ci(travis): added missing closing quote to travis.yml * ci(travis): add conditional to travis.yml
1 parent 6de01d0 commit daf94f3

File tree

22 files changed

+3482
-2046
lines changed

22 files changed

+3482
-2046
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ node_js:
55
- 6
66
- stable
77
before_install:
8-
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_7f9951a7b27b_key
9-
-iv $encrypted_7f9951a7b27b_iv -in auth.js.enc -out test/resources/auth.js -d ||
8+
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_320e4a7e27b3_key
9+
-iv $encrypted_320e4a7e27b3_iv -in auth.js.enc -out test/resources/auth.js -d ||
1010
true'
1111
- npm install -g typescript
1212
script:
1313
- tsc
14-
- npm run test-travis
14+
- 'if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then npm run test-travis; fi'
15+
- 'if [ "${TRAVIS_PULL_REQUEST}" = "true" ]; then npm run test-unit; fi'
1516
- sh scripts/typedoc/generate_typedoc.sh
1617
after_success:
1718
- npm run report-coverage

README.md

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ Node.js client library to use the Watson APIs.
2424
* [Authorization](#authorization)
2525
* [Assistant](#assistant)
2626
* [Discovery](#discovery)
27-
* [Language Translator](#language-translator)
27+
* [Language Translator v3](#language-translator-v3)
28+
* [Language Translator v2](#language-translator-v2)
2829
* [Natural Language Classifier](#natural-language-classifier)
2930
* [Natural Language Understanding](#natural-language-understanding)
3031
* [Personality Insights](#personality-insights)
@@ -82,7 +83,7 @@ const discovery = new DiscoveryV1({
8283
url: '<service_url>',
8384
version: '<version-date>',
8485
iam_apikey: '<iam_api_key>',
85-
iam_url: '<iam_url>', // optional - the default value is https://iam.ng.bluemix.net/identity/token
86+
iam_url: '<iam_url>', // optional - the default value is https://iam.bluemix.net/identity/token
8687
});
8788
```
8889

@@ -299,10 +300,52 @@ discovery.query(
299300
}
300301
}
301302
);
303+
302304
```
305+
### Language Translator v3
306+
307+
Translate text from one language to another or idenfity a language using the [Language Translator][language_translator] service.
308+
309+
```javascript
310+
var LanguageTranslatorV3 = require('watson-developer-cloud/language-translator/v3');
303311

312+
var languageTranslator = new LanguageTranslatorV3({
313+
username: '<username>',
314+
password: '<password>',
315+
url: 'https://gateway.watsonplatform.net/language-translator/api/',
316+
version: 'YYYY-MM-DD',
317+
});
318+
319+
languageTranslator.translate(
320+
{
321+
text: 'A sentence must have a verb',
322+
source: 'en',
323+
target: 'es'
324+
},
325+
function(err, translation) {
326+
if (err) {
327+
console.log('error:', err);
328+
} else {
329+
console.log(JSON.stringify(translation, null, 2));
330+
}
331+
);
332+
333+
languageTranslator.identify(
334+
{
335+
text:
336+
'The language translator service takes text input and identifies the language used.'
337+
},
338+
function(err, language) {
339+
if (err) {
340+
console.log('error:', err);
341+
} else {
342+
console.log(JSON.stringify(language, null, 2));
343+
}
344+
}
345+
);
346+
```
304347
305-
### Language Translator
348+
### Language Translator v2
306349
307350
Translate text from one language to another or idenfity a language using the [Language Translator][language_translator] service.
308351

assistant/v1.ts

Lines changed: 417 additions & 554 deletions
Large diffs are not rendered by default.

auth.js.enc

-32 Bytes
Binary file not shown.

conversation/v1-generated.ts

Lines changed: 418 additions & 555 deletions
Large diffs are not rendered by default.

discovery/v1-generated.ts

Lines changed: 332 additions & 255 deletions
Large diffs are not rendered by default.

index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export import DialogV1 = require('./dialog/v1');
3030

3131
export import LanguageTranslatorV2 = require('./language-translator/v2');
3232

33+
export import LanguageTranslatorV3 = require('./language-translator/v3');
34+
3335
export import NaturalLanguageClassifierV1 = require('./natural-language-classifier/v1');
3436

3537
export import NaturalLanguageUnderstandingV1 = require('./natural-language-understanding/v1');

language-translator/v2-generated.ts

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { getMissingParams } from '../lib/helper';
2121
import { FileObject } from '../lib/helper';
2222

2323
/**
24-
* IBM Watson Language Translator translates text from one language to another. The service offers multiple domain-specific models that you can customize based on your unique terminology and language. Use Language Translator to take news from across the globe and present it in your language, communicate with your customers in their own language, and more.
24+
* IBM Watson&trade; Language Translator translates text from one language to another. The service offers multiple domain-specific models that you can customize based on your unique terminology and language. Use Language Translator to take news from across the globe and present it in your language, communicate with your customers in their own language, and more.
2525
*/
2626

2727
class LanguageTranslatorV2 extends BaseService {
@@ -60,10 +60,16 @@ class LanguageTranslatorV2 extends BaseService {
6060
* Translates the input text from the source language to the target language.
6161
*
6262
* @param {Object} params - The parameters to send to the service.
63-
* @param {string[]} params.text - Input text in UTF-8 encoding. Multiple entries will result in multiple translations in the response.
64-
* @param {string} [params.model_id] - Model ID of the translation model to use. If this is specified, the **source** and **target** parameters will be ignored. The method requires either a model ID or both the **source** and **target** parameters.
65-
* @param {string} [params.source] - Language code of the source text language. Use with `target` as an alternative way to select a translation model. When `source` and `target` are set, and a model ID is not set, the system chooses a default model for the language pair (usually the model based on the news domain).
66-
* @param {string} [params.target] - Language code of the translation target language. Use with source as an alternative way to select a translation model.
63+
* @param {string[]} params.text - Input text in UTF-8 encoding. Multiple entries will result in multiple translations
64+
* in the response.
65+
* @param {string} [params.model_id] - Model ID of the translation model to use. If this is specified, the **source**
66+
* and **target** parameters will be ignored. The method requires either a model ID or both the **source** and
67+
* **target** parameters.
68+
* @param {string} [params.source] - Language code of the source text language. Use with `target` as an alternative
69+
* way to select a translation model. When `source` and `target` are set, and a model ID is not set, the system
70+
* chooses a default model for the language pair (usually the model based on the news domain).
71+
* @param {string} [params.target] - Language code of the translation target language. Use with source as an
72+
* alternative way to select a translation model.
6773
* @param {Object} [params.headers] - Custom request headers
6874
* @param {Function} [callback] - The callback that handles the response.
6975
* @returns {NodeJS.ReadableStream|void}
@@ -143,7 +149,8 @@ class LanguageTranslatorV2 extends BaseService {
143149
/**
144150
* List identifiable languages.
145151
*
146-
* Lists the languages that the service can identify. Returns the language code (for example, `en` for English or `es` for Spanish) and name of each language.
152+
* Lists the languages that the service can identify. Returns the language code (for example, `en` for English or `es`
153+
* for Spanish) and name of each language.
147154
*
148155
* @param {Object} [params] - The parameters to send to the service.
149156
* @param {Object} [params.headers] - Custom request headers
@@ -174,14 +181,24 @@ class LanguageTranslatorV2 extends BaseService {
174181
/**
175182
* Create model.
176183
*
177-
* Uploads a TMX glossary file on top of a domain to customize a translation model. Depending on the size of the file, training can range from minutes for a glossary to several hours for a large parallel corpus. Glossary files must be less than 10 MB. The cumulative file size of all uploaded glossary and corpus files is limited to 250 MB.
184+
* Uploads a TMX glossary file on top of a domain to customize a translation model.
185+
*
186+
* Depending on the size of the file, training can range from minutes for a glossary to several hours for a large
187+
* parallel corpus. Glossary files must be less than 10 MB. The cumulative file size of all uploaded glossary and
188+
* corpus files is limited to 250 MB.
178189
*
179190
* @param {Object} params - The parameters to send to the service.
180-
* @param {string} params.base_model_id - The model ID of the model to use as the base for customization. To see available models, use the `List models` method.
181-
* @param {string} [params.name] - An optional model name that you can use to identify the model. Valid characters are letters, numbers, dashes, underscores, spaces and apostrophes. The maximum length is 32 characters.
182-
* @param {NodeJS.ReadableStream|FileObject|Buffer} [params.forced_glossary] - A TMX file with your customizations. The customizations in the file completely overwrite the domain translaton data, including high frequency or high confidence phrase translations. You can upload only one glossary with a file size less than 10 MB per call.
183-
* @param {NodeJS.ReadableStream|FileObject|Buffer} [params.parallel_corpus] - A TMX file that contains entries that are treated as a parallel corpus instead of a glossary.
184-
* @param {NodeJS.ReadableStream|FileObject|Buffer} [params.monolingual_corpus] - A UTF-8 encoded plain text file that is used to customize the target language model.
191+
* @param {string} params.base_model_id - The model ID of the model to use as the base for customization. To see
192+
* available models, use the `List models` method.
193+
* @param {string} [params.name] - An optional model name that you can use to identify the model. Valid characters are
194+
* letters, numbers, dashes, underscores, spaces and apostrophes. The maximum length is 32 characters.
195+
* @param {NodeJS.ReadableStream|FileObject|Buffer} [params.forced_glossary] - A TMX file with your customizations.
196+
* The customizations in the file completely overwrite the domain translaton data, including high frequency or high
197+
* confidence phrase translations. You can upload only one glossary with a file size less than 10 MB per call.
198+
* @param {NodeJS.ReadableStream|FileObject|Buffer} [params.parallel_corpus] - A TMX file that contains entries that
199+
* are treated as a parallel corpus instead of a glossary.
200+
* @param {NodeJS.ReadableStream|FileObject|Buffer} [params.monolingual_corpus] - A UTF-8 encoded plain text file that
201+
* is used to customize the target language model.
185202
* @param {Object} [params.headers] - Custom request headers
186203
* @param {Function} [callback] - The callback that handles the response.
187204
* @returns {NodeJS.ReadableStream|void}
@@ -311,7 +328,9 @@ class LanguageTranslatorV2 extends BaseService {
311328
* @param {Object} [params] - The parameters to send to the service.
312329
* @param {string} [params.source] - Specify a language code to filter results by source language.
313330
* @param {string} [params.target] - Specify a language code to filter results by target language.
314-
* @param {boolean} [params.default_models] - If the default parameter isn't specified, the service will return all models (default and non-default) for each language pair. To return only default models, set this to `true`. To return only non-default models, set this to `false`.
331+
* @param {boolean} [params.default_models] - If the default parameter isn't specified, the service will return all
332+
* models (default and non-default) for each language pair. To return only default models, set this to `true`. To
333+
* return only non-default models, set this to `false`.
315334
* @param {Object} [params.headers] - Custom request headers
316335
* @param {Function} [callback] - The callback that handles the response.
317336
* @returns {NodeJS.ReadableStream|void}
@@ -447,14 +466,6 @@ namespace LanguageTranslatorV2 {
447466
status: string;
448467
}
449468

450-
/** ErrorResponse. */
451-
export interface ErrorResponse {
452-
/** A short identifier for the error. */
453-
error_code: string;
454-
/** A more detailed description of the error. */
455-
error_message: string;
456-
}
457-
458469
/** IdentifiableLanguage. */
459470
export interface IdentifiableLanguage {
460471
/** The language code for an identifiable language. */
@@ -483,18 +494,6 @@ namespace LanguageTranslatorV2 {
483494
languages: IdentifiedLanguage[];
484495
}
485496

486-
/** TranslateRequest. */
487-
export interface TranslateRequest {
488-
/** Input text in UTF-8 encoding. Multiple entries will result in multiple translations in the response. */
489-
text: string[];
490-
/** Model ID of the translation model to use. If this is specified, the **source** and **target** parameters will be ignored. The method requires either a model ID or both the **source** and **target** parameters. */
491-
model_id?: string;
492-
/** Language code of the source text language. Use with `target` as an alternative way to select a translation model. When `source` and `target` are set, and a model ID is not set, the system chooses a default model for the language pair (usually the model based on the news domain). */
493-
source?: string;
494-
/** Language code of the translation target language. Use with source as an alternative way to select a translation model. */
495-
target?: string;
496-
}
497-
498497
/** Translation. */
499498
export interface Translation {
500499
/** Translation output in UTF-8. */
@@ -543,4 +542,4 @@ namespace LanguageTranslatorV2 {
543542

544543
}
545544

546-
export = LanguageTranslatorV2;
545+
export = LanguageTranslatorV2;

0 commit comments

Comments
 (0)