Skip to content

Commit

Permalink
Regeneration of services with language translator v3 (watson-develope…
Browse files Browse the repository at this point in the history
…r-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
  • Loading branch information
anweshan authored Jun 13, 2018
1 parent 6de01d0 commit daf94f3
Show file tree
Hide file tree
Showing 22 changed files with 3,482 additions and 2,046 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ node_js:
- 6
- stable
before_install:
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_7f9951a7b27b_key
-iv $encrypted_7f9951a7b27b_iv -in auth.js.enc -out test/resources/auth.js -d ||
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_320e4a7e27b3_key
-iv $encrypted_320e4a7e27b3_iv -in auth.js.enc -out test/resources/auth.js -d ||
true'
- npm install -g typescript
script:
- tsc
- npm run test-travis
- 'if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then npm run test-travis; fi'
- 'if [ "${TRAVIS_PULL_REQUEST}" = "true" ]; then npm run test-unit; fi'
- sh scripts/typedoc/generate_typedoc.sh
after_success:
- npm run report-coverage
Expand Down
49 changes: 46 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Node.js client library to use the Watson APIs.
* [Authorization](#authorization)
* [Assistant](#assistant)
* [Discovery](#discovery)
* [Language Translator](#language-translator)
* [Language Translator v3](#language-translator-v3)
* [Language Translator v2](#language-translator-v2)
* [Natural Language Classifier](#natural-language-classifier)
* [Natural Language Understanding](#natural-language-understanding)
* [Personality Insights](#personality-insights)
Expand Down Expand Up @@ -82,7 +83,7 @@ const discovery = new DiscoveryV1({
url: '<service_url>',
version: '<version-date>',
iam_apikey: '<iam_api_key>',
iam_url: '<iam_url>', // optional - the default value is https://iam.ng.bluemix.net/identity/token
iam_url: '<iam_url>', // optional - the default value is https://iam.bluemix.net/identity/token
});
```

Expand Down Expand Up @@ -299,10 +300,52 @@ discovery.query(
}
}
);

```
### Language Translator v3

Translate text from one language to another or idenfity a language using the [Language Translator][language_translator] service.

```javascript
var LanguageTranslatorV3 = require('watson-developer-cloud/language-translator/v3');

var languageTranslator = new LanguageTranslatorV3({
username: '<username>',
password: '<password>',
url: 'https://gateway.watsonplatform.net/language-translator/api/',
version: 'YYYY-MM-DD',
});

languageTranslator.translate(
{
text: 'A sentence must have a verb',
source: 'en',
target: 'es'
},
function(err, translation) {
if (err) {
console.log('error:', err);
} else {
console.log(JSON.stringify(translation, null, 2));
}
);

languageTranslator.identify(
{
text:
'The language translator service takes text input and identifies the language used.'
},
function(err, language) {
if (err) {
console.log('error:', err);
} else {
console.log(JSON.stringify(language, null, 2));
}
}
);
```
### Language Translator
### Language Translator v2
Translate text from one language to another or idenfity a language using the [Language Translator][language_translator] service.
Expand Down
971 changes: 417 additions & 554 deletions assistant/v1.ts

Large diffs are not rendered by default.

Binary file modified auth.js.enc
Binary file not shown.
973 changes: 418 additions & 555 deletions conversation/v1-generated.ts

Large diffs are not rendered by default.

587 changes: 332 additions & 255 deletions discovery/v1-generated.ts

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export import DialogV1 = require('./dialog/v1');

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

export import LanguageTranslatorV3 = require('./language-translator/v3');

export import NaturalLanguageClassifierV1 = require('./natural-language-classifier/v1');

export import NaturalLanguageUnderstandingV1 = require('./natural-language-understanding/v1');
Expand Down
67 changes: 33 additions & 34 deletions language-translator/v2-generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { getMissingParams } from '../lib/helper';
import { FileObject } from '../lib/helper';

/**
* 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.
* 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.
*/

class LanguageTranslatorV2 extends BaseService {
Expand Down Expand Up @@ -60,10 +60,16 @@ class LanguageTranslatorV2 extends BaseService {
* Translates the input text from the source language to the target language.
*
* @param {Object} params - The parameters to send to the service.
* @param {string[]} params.text - Input text in UTF-8 encoding. Multiple entries will result in multiple translations in the response.
* @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.
* @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).
* @param {string} [params.target] - Language code of the translation target language. Use with source as an alternative way to select a translation model.
* @param {string[]} params.text - Input text in UTF-8 encoding. Multiple entries will result in multiple translations
* in the response.
* @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.
* @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).
* @param {string} [params.target] - Language code of the translation target language. Use with source as an
* alternative way to select a translation model.
* @param {Object} [params.headers] - Custom request headers
* @param {Function} [callback] - The callback that handles the response.
* @returns {NodeJS.ReadableStream|void}
Expand Down Expand Up @@ -143,7 +149,8 @@ class LanguageTranslatorV2 extends BaseService {
/**
* List identifiable languages.
*
* 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.
* 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.
*
* @param {Object} [params] - The parameters to send to the service.
* @param {Object} [params.headers] - Custom request headers
Expand Down Expand Up @@ -174,14 +181,24 @@ class LanguageTranslatorV2 extends BaseService {
/**
* Create model.
*
* 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.
* 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.
*
* @param {Object} params - The parameters to send to the service.
* @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.
* @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.
* @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.
* @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.
* @param {NodeJS.ReadableStream|FileObject|Buffer} [params.monolingual_corpus] - A UTF-8 encoded plain text file that is used to customize the target language model.
* @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.
* @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.
* @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.
* @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.
* @param {NodeJS.ReadableStream|FileObject|Buffer} [params.monolingual_corpus] - A UTF-8 encoded plain text file that
* is used to customize the target language model.
* @param {Object} [params.headers] - Custom request headers
* @param {Function} [callback] - The callback that handles the response.
* @returns {NodeJS.ReadableStream|void}
Expand Down Expand Up @@ -311,7 +328,9 @@ class LanguageTranslatorV2 extends BaseService {
* @param {Object} [params] - The parameters to send to the service.
* @param {string} [params.source] - Specify a language code to filter results by source language.
* @param {string} [params.target] - Specify a language code to filter results by target language.
* @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`.
* @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`.
* @param {Object} [params.headers] - Custom request headers
* @param {Function} [callback] - The callback that handles the response.
* @returns {NodeJS.ReadableStream|void}
Expand Down Expand Up @@ -447,14 +466,6 @@ namespace LanguageTranslatorV2 {
status: string;
}

/** ErrorResponse. */
export interface ErrorResponse {
/** A short identifier for the error. */
error_code: string;
/** A more detailed description of the error. */
error_message: string;
}

/** IdentifiableLanguage. */
export interface IdentifiableLanguage {
/** The language code for an identifiable language. */
Expand Down Expand Up @@ -483,18 +494,6 @@ namespace LanguageTranslatorV2 {
languages: IdentifiedLanguage[];
}

/** TranslateRequest. */
export interface TranslateRequest {
/** Input text in UTF-8 encoding. Multiple entries will result in multiple translations in the response. */
text: string[];
/** 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. */
model_id?: string;
/** 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). */
source?: string;
/** Language code of the translation target language. Use with source as an alternative way to select a translation model. */
target?: string;
}

/** Translation. */
export interface Translation {
/** Translation output in UTF-8. */
Expand Down Expand Up @@ -543,4 +542,4 @@ namespace LanguageTranslatorV2 {

}

export = LanguageTranslatorV2;
export = LanguageTranslatorV2;
Loading

0 comments on commit daf94f3

Please sign in to comment.