languagetranslatorv3

package
v3.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package languagetranslatorv3 : Operations and models for the LanguageTranslatorV3 service

Index

Constants

View Source
const (
	DocumentStatusStatusAvailableConst  = "available"
	DocumentStatusStatusFailedConst     = "failed"
	DocumentStatusStatusProcessingConst = "processing"
)

Constants associated with the DocumentStatus.Status property. The status of the translation job associated with a submitted document.

View Source
const (
	TranslationModelStatusAvailableConst   = "available"
	TranslationModelStatusDeletedConst     = "deleted"
	TranslationModelStatusDispatchingConst = "dispatching"
	TranslationModelStatusErrorConst       = "error"
	TranslationModelStatusPublishingConst  = "publishing"
	TranslationModelStatusQueuedConst      = "queued"
	TranslationModelStatusTrainedConst     = "trained"
	TranslationModelStatusTrainingConst    = "training"
	TranslationModelStatusUploadedConst    = "uploaded"
	TranslationModelStatusUploadingConst   = "uploading"
)

Constants associated with the TranslationModel.Status property. Availability of a model.

View Source
const DefaultServiceName = "language_translator"

DefaultServiceName is the default key used to find external configuration information.

View Source
const DefaultServiceURL = "https://api.us-south.language-translator.watson.cloud.ibm.com"

DefaultServiceURL is the default URL to make service requests to.

Variables

This section is empty.

Functions

func GetServiceURLForRegion

func GetServiceURLForRegion(region string) (string, error)

GetServiceURLForRegion returns the service URL to be used for the specified region

func UnmarshalDeleteModelResult

func UnmarshalDeleteModelResult(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalDeleteModelResult unmarshals an instance of DeleteModelResult from the specified map of raw messages.

func UnmarshalDocumentList

func UnmarshalDocumentList(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalDocumentList unmarshals an instance of DocumentList from the specified map of raw messages.

func UnmarshalDocumentStatus

func UnmarshalDocumentStatus(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalDocumentStatus unmarshals an instance of DocumentStatus from the specified map of raw messages.

func UnmarshalIdentifiableLanguage

func UnmarshalIdentifiableLanguage(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalIdentifiableLanguage unmarshals an instance of IdentifiableLanguage from the specified map of raw messages.

func UnmarshalIdentifiableLanguages

func UnmarshalIdentifiableLanguages(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalIdentifiableLanguages unmarshals an instance of IdentifiableLanguages from the specified map of raw messages.

func UnmarshalIdentifiedLanguage

func UnmarshalIdentifiedLanguage(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalIdentifiedLanguage unmarshals an instance of IdentifiedLanguage from the specified map of raw messages.

func UnmarshalIdentifiedLanguages

func UnmarshalIdentifiedLanguages(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalIdentifiedLanguages unmarshals an instance of IdentifiedLanguages from the specified map of raw messages.

func UnmarshalLanguage

func UnmarshalLanguage(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalLanguage unmarshals an instance of Language from the specified map of raw messages.

func UnmarshalLanguages

func UnmarshalLanguages(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalLanguages unmarshals an instance of Languages from the specified map of raw messages.

func UnmarshalTranslation

func UnmarshalTranslation(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalTranslation unmarshals an instance of Translation from the specified map of raw messages.

func UnmarshalTranslationModel

func UnmarshalTranslationModel(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalTranslationModel unmarshals an instance of TranslationModel from the specified map of raw messages.

func UnmarshalTranslationModels

func UnmarshalTranslationModels(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalTranslationModels unmarshals an instance of TranslationModels from the specified map of raw messages.

func UnmarshalTranslationResult

func UnmarshalTranslationResult(m map[string]json.RawMessage, result interface{}) (err error)

UnmarshalTranslationResult unmarshals an instance of TranslationResult from the specified map of raw messages.

Types

type CreateModelOptions

type CreateModelOptions struct {
	// The ID of the translation model to use as the base for customization. To see available models and IDs, use the `List
	// models` method. Most models that are provided with the service are customizable. In addition, all models that you
	// create with parallel corpora customization can be further customized with a forced glossary.
	BaseModelID *string `json:"base_model_id" validate:"required"`

	// A file with forced glossary terms for the source and target languages. The customizations in the file completely
	// overwrite the domain translation data, including high frequency or high confidence phrase translations.
	//
	// You can upload only one glossary file for a custom model, and the glossary can have a maximum size of 10 MB. A
	// forced glossary must contain single words or short phrases. For more information, see **Supported file formats** in
	// the method description.
	//
	// *With `curl`, use `--form forced_glossary=@{filename}`.*.
	ForcedGlossary io.ReadCloser `json:"forced_glossary,omitempty"`

	// A file with parallel sentences for the source and target languages. You can upload multiple parallel corpus files in
	// one request by repeating the parameter. All uploaded parallel corpus files combined must contain at least 5000
	// parallel sentences to train successfully. You can provide a maximum of 500,000 parallel sentences across all
	// corpora.
	//
	// A single entry in a corpus file can contain a maximum of 80 words. All corpora files for a custom model can have a
	// cumulative maximum size of 250 MB. For more information, see **Supported file formats** in the method description.
	//
	// *With `curl`, use `--form parallel_corpus=@{filename}`.*.
	ParallelCorpus io.ReadCloser `json:"parallel_corpus,omitempty"`

	// 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 of the name is 32 characters.
	Name *string `json:"name,omitempty"`

	// Allows users to set headers on API requests
	Headers map[string]string
}

CreateModelOptions : The CreateModel options.

func (*CreateModelOptions) SetBaseModelID

func (_options *CreateModelOptions) SetBaseModelID(baseModelID string) *CreateModelOptions

SetBaseModelID : Allow user to set BaseModelID

func (*CreateModelOptions) SetForcedGlossary

func (_options *CreateModelOptions) SetForcedGlossary(forcedGlossary io.ReadCloser) *CreateModelOptions

SetForcedGlossary : Allow user to set ForcedGlossary

func (*CreateModelOptions) SetHeaders

func (options *CreateModelOptions) SetHeaders(param map[string]string) *CreateModelOptions

SetHeaders : Allow user to set Headers

func (*CreateModelOptions) SetName

func (_options *CreateModelOptions) SetName(name string) *CreateModelOptions

SetName : Allow user to set Name

func (*CreateModelOptions) SetParallelCorpus

func (_options *CreateModelOptions) SetParallelCorpus(parallelCorpus io.ReadCloser) *CreateModelOptions

SetParallelCorpus : Allow user to set ParallelCorpus

type DeleteDocumentOptions

type DeleteDocumentOptions struct {
	// Document ID of the document to delete.
	DocumentID *string `json:"document_id" validate:"required,ne="`

	// Allows users to set headers on API requests
	Headers map[string]string
}

DeleteDocumentOptions : The DeleteDocument options.

func (*DeleteDocumentOptions) SetDocumentID

func (_options *DeleteDocumentOptions) SetDocumentID(documentID string) *DeleteDocumentOptions

SetDocumentID : Allow user to set DocumentID

func (*DeleteDocumentOptions) SetHeaders

func (options *DeleteDocumentOptions) SetHeaders(param map[string]string) *DeleteDocumentOptions

SetHeaders : Allow user to set Headers

type DeleteModelOptions

type DeleteModelOptions struct {
	// Model ID of the model to delete.
	ModelID *string `json:"model_id" validate:"required,ne="`

	// Allows users to set headers on API requests
	Headers map[string]string
}

DeleteModelOptions : The DeleteModel options.

func (*DeleteModelOptions) SetHeaders

func (options *DeleteModelOptions) SetHeaders(param map[string]string) *DeleteModelOptions

SetHeaders : Allow user to set Headers

func (*DeleteModelOptions) SetModelID

func (_options *DeleteModelOptions) SetModelID(modelID string) *DeleteModelOptions

SetModelID : Allow user to set ModelID

type DeleteModelResult

type DeleteModelResult struct {
	// "OK" indicates that the model was successfully deleted.
	Status *string `json:"status" validate:"required"`
}

DeleteModelResult : DeleteModelResult struct

type DocumentList

type DocumentList struct {
	// An array of all previously submitted documents.
	Documents []DocumentStatus `json:"documents" validate:"required"`
}

DocumentList : DocumentList struct

type DocumentStatus

type DocumentStatus struct {
	// System generated ID identifying a document being translated using one specific translation model.
	DocumentID *string `json:"document_id" validate:"required"`

	// filename from the submission (if it was missing in the multipart-form, 'noname.<ext matching content type>' is used.
	Filename *string `json:"filename" validate:"required"`

	// The status of the translation job associated with a submitted document.
	Status *string `json:"status" validate:"required"`

	// A globally unique string that identifies the underlying model that is used for translation.
	ModelID *string `json:"model_id" validate:"required"`

	// Model ID of the base model that was used to customize the model. If the model is not a custom model, this will be
	// absent or an empty string.
	BaseModelID *string `json:"base_model_id,omitempty"`

	// Translation source language code.
	Source *string `json:"source" validate:"required"`

	// A score between 0 and 1 indicating the confidence of source language detection. A higher value indicates greater
	// confidence. This is returned only when the service automatically detects the source language.
	DetectedLanguageConfidence *float64 `json:"detected_language_confidence,omitempty"`

	// Translation target language code.
	Target *string `json:"target" validate:"required"`

	// The time when the document was submitted.
	Created *strfmt.DateTime `json:"created" validate:"required"`

	// The time when the translation completed.
	Completed *strfmt.DateTime `json:"completed,omitempty"`

	// An estimate of the number of words in the source document. Returned only if `status` is `available`.
	WordCount *int64 `json:"word_count,omitempty"`

	// The number of characters in the source document, present only if status=available.
	CharacterCount *int64 `json:"character_count,omitempty"`
}

DocumentStatus : Document information, including translation status.

type GetDocumentStatusOptions

type GetDocumentStatusOptions struct {
	// The document ID of the document.
	DocumentID *string `json:"document_id" validate:"required,ne="`

	// Allows users to set headers on API requests
	Headers map[string]string
}

GetDocumentStatusOptions : The GetDocumentStatus options.

func (*GetDocumentStatusOptions) SetDocumentID

func (_options *GetDocumentStatusOptions) SetDocumentID(documentID string) *GetDocumentStatusOptions

SetDocumentID : Allow user to set DocumentID

func (*GetDocumentStatusOptions) SetHeaders

func (options *GetDocumentStatusOptions) SetHeaders(param map[string]string) *GetDocumentStatusOptions

SetHeaders : Allow user to set Headers

type GetModelOptions

type GetModelOptions struct {
	// Model ID of the model to get.
	ModelID *string `json:"model_id" validate:"required,ne="`

	// Allows users to set headers on API requests
	Headers map[string]string
}

GetModelOptions : The GetModel options.

func (*GetModelOptions) SetHeaders

func (options *GetModelOptions) SetHeaders(param map[string]string) *GetModelOptions

SetHeaders : Allow user to set Headers

func (*GetModelOptions) SetModelID

func (_options *GetModelOptions) SetModelID(modelID string) *GetModelOptions

SetModelID : Allow user to set ModelID

type GetTranslatedDocumentOptions

type GetTranslatedDocumentOptions struct {
	// The document ID of the document that was submitted for translation.
	DocumentID *string `json:"document_id" validate:"required,ne="`

	// The type of the response: application/powerpoint, application/mspowerpoint, application/x-rtf, application/json,
	// application/xml, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,
	// application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation,
	// application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document,
	// application/vnd.oasis.opendocument.spreadsheet, application/vnd.oasis.opendocument.presentation,
	// application/vnd.oasis.opendocument.text, application/pdf, application/rtf, text/html, text/json, text/plain,
	// text/richtext, text/rtf, or text/xml. A character encoding can be specified by including a `charset` parameter. For
	// example, 'text/html;charset=utf-8'.
	Accept *string `json:"Accept,omitempty"`

	// Allows users to set headers on API requests
	Headers map[string]string
}

GetTranslatedDocumentOptions : The GetTranslatedDocument options.

func (*GetTranslatedDocumentOptions) SetAccept

SetAccept : Allow user to set Accept

func (*GetTranslatedDocumentOptions) SetDocumentID

func (_options *GetTranslatedDocumentOptions) SetDocumentID(documentID string) *GetTranslatedDocumentOptions

SetDocumentID : Allow user to set DocumentID

func (*GetTranslatedDocumentOptions) SetHeaders

SetHeaders : Allow user to set Headers

type IdentifiableLanguage

type IdentifiableLanguage struct {
	// The language code for an identifiable language.
	Language *string `json:"language" validate:"required"`

	// The name of the identifiable language.
	Name *string `json:"name" validate:"required"`
}

IdentifiableLanguage : IdentifiableLanguage struct

type IdentifiableLanguages

type IdentifiableLanguages struct {
	// A list of all languages that the service can identify.
	Languages []IdentifiableLanguage `json:"languages" validate:"required"`
}

IdentifiableLanguages : IdentifiableLanguages struct

type IdentifiedLanguage

type IdentifiedLanguage struct {
	// The language code for an identified language.
	Language *string `json:"language" validate:"required"`

	// The confidence score for the identified language.
	Confidence *float64 `json:"confidence" validate:"required"`
}

IdentifiedLanguage : IdentifiedLanguage struct

type IdentifiedLanguages

type IdentifiedLanguages struct {
	// A ranking of identified languages with confidence scores.
	Languages []IdentifiedLanguage `json:"languages" validate:"required"`
}

IdentifiedLanguages : IdentifiedLanguages struct

type IdentifyOptions

type IdentifyOptions struct {
	// Input text in UTF-8 format.
	Text *string `json:"text" validate:"required"`

	// Allows users to set headers on API requests
	Headers map[string]string
}

IdentifyOptions : The Identify options.

func (*IdentifyOptions) SetHeaders

func (options *IdentifyOptions) SetHeaders(param map[string]string) *IdentifyOptions

SetHeaders : Allow user to set Headers

func (*IdentifyOptions) SetText

func (_options *IdentifyOptions) SetText(text string) *IdentifyOptions

SetText : Allow user to set Text

type Language

type Language struct {
	// The language code for the language (for example, `af`).
	Language *string `json:"language,omitempty"`

	// The name of the language in English (for example, `Afrikaans`).
	LanguageName *string `json:"language_name,omitempty"`

	// The native name of the language (for example, `Afrikaans`).
	NativeLanguageName *string `json:"native_language_name,omitempty"`

	// The country code for the language (for example, `ZA` for South Africa).
	CountryCode *string `json:"country_code,omitempty"`

	// Indicates whether words of the language are separated by whitespace: `true` if the words are separated; `false`
	// otherwise.
	WordsSeparated *bool `json:"words_separated,omitempty"`

	// Indicates the direction of the language: `right_to_left` or `left_to_right`.
	Direction *string `json:"direction,omitempty"`

	// Indicates whether the language can be used as the source for translation: `true` if the language can be used as the
	// source; `false` otherwise.
	SupportedAsSource *bool `json:"supported_as_source,omitempty"`

	// Indicates whether the language can be used as the target for translation: `true` if the language can be used as the
	// target; `false` otherwise.
	SupportedAsTarget *bool `json:"supported_as_target,omitempty"`

	// Indicates whether the language supports automatic detection: `true` if the language can be detected automatically;
	// `false` otherwise.
	Identifiable *bool `json:"identifiable,omitempty"`
}

Language : Response payload for languages.

type LanguageTranslatorV3

type LanguageTranslatorV3 struct {
	Service *core.BaseService

	// Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. The current version is
	// `2018-05-01`.
	Version *string
}

LanguageTranslatorV3 : IBM Watson&trade; Language Translator translates text from one language to another. The service offers multiple IBM-provided translation 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.

API Version: 3.0.0 See: https://cloud.ibm.com/docs/language-translator

func NewLanguageTranslatorV3

func NewLanguageTranslatorV3(options *LanguageTranslatorV3Options) (service *LanguageTranslatorV3, err error)

NewLanguageTranslatorV3 : constructs an instance of LanguageTranslatorV3 with passed in options.

func (*LanguageTranslatorV3) Clone

func (languageTranslator *LanguageTranslatorV3) Clone() *LanguageTranslatorV3

Clone makes a copy of "languageTranslator" suitable for processing requests.

func (*LanguageTranslatorV3) CreateModel

func (languageTranslator *LanguageTranslatorV3) CreateModel(createModelOptions *CreateModelOptions) (result *TranslationModel, response *core.DetailedResponse, err error)

CreateModel : Create model Uploads training files to customize a translation model. You can customize a model with a forced glossary or with a parallel corpus: * Use a *forced glossary* to force certain terms and phrases to be translated in a specific way. You can upload only a single forced glossary file for a model. The size of a forced glossary file for a custom model is limited to 10 MB. * Use a *parallel corpus* when you want your custom model to learn from general translation patterns in parallel sentences in your samples. What your model learns from a parallel corpus can improve translation results for input text that the model has not been trained on. You can upload multiple parallel corpora files with a request. To successfully train with parallel corpora, the corpora files must contain a cumulative total of at least 5000 parallel sentences. The cumulative size of all uploaded corpus files for a custom model is limited to 250 MB.

Depending on the type of customization and the size of the uploaded files, training time can range from minutes for a glossary to several hours for a large parallel corpus. To create a model that is customized with a parallel corpus and a forced glossary, customize the model with a parallel corpus first and then customize the resulting model with a forced glossary.

You can create a maximum of 10 custom models per language pair. For more information about customizing a translation model, including the formatting and character restrictions for data files, see [Customizing your model](https://cloud.ibm.com/docs/language-translator?topic=language-translator-customizing).

#### Supported file formats

You can provide your training data for customization in the following document formats:

* **TMX** (`.tmx`) - Translation Memory eXchange (TMX) is an XML specification for the exchange of translation memories. * **XLIFF** (`.xliff`) - XML Localization Interchange File Format (XLIFF) is an XML specification for the exchange of translation memories. * **CSV** (`.csv`) - Comma-separated values (CSV) file with two columns for aligned sentences and phrases. The first row must have two language codes. The first column is for the source language code, and the second column is for the target language code. * **TSV** (`.tsv` or `.tab`) - Tab-separated values (TSV) file with two columns for aligned sentences and phrases. The first row must have two language codes. The first column is for the source language code, and the second column is for the target language code. * **JSON** (`.json`) - Custom JSON format for specifying aligned sentences and phrases. * **Microsoft Excel** (`.xls` or `.xlsx`) - Excel file with the first two columns for aligned sentences and phrases. The first row contains the language code.

You must encode all text data in UTF-8 format. For more information, see [Supported document formats for training data](https://cloud.ibm.com/docs/language-translator?topic=language-translator-customizing#supported-document-formats-for-training-data).

#### Specifying file formats

You can indicate the format of a file by including the file extension with the file name. Use the file extensions

shown in **Supported file formats**.

Alternatively, you can omit the file extension and specify one of the following `content-type` specifications for the file: * **TMX** - `application/x-tmx+xml` * **XLIFF** - `application/xliff+xml` * **CSV** - `text/csv` * **TSV** - `text/tab-separated-values` * **JSON** - `application/json` * **Microsoft Excel** - `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`

For example, with `curl`, use the following `content-type` specification to indicate the format of a CSV file named **glossary**:

`--form "forced_glossary=@glossary;type=text/csv"`.

func (*LanguageTranslatorV3) CreateModelWithContext

func (languageTranslator *LanguageTranslatorV3) CreateModelWithContext(ctx context.Context, createModelOptions *CreateModelOptions) (result *TranslationModel, response *core.DetailedResponse, err error)

CreateModelWithContext is an alternate form of the CreateModel method which supports a Context parameter

func (*LanguageTranslatorV3) DeleteDocument

func (languageTranslator *LanguageTranslatorV3) DeleteDocument(deleteDocumentOptions *DeleteDocumentOptions) (response *core.DetailedResponse, err error)

DeleteDocument : Delete document Deletes a document.

func (*LanguageTranslatorV3) DeleteDocumentWithContext

func (languageTranslator *LanguageTranslatorV3) DeleteDocumentWithContext(ctx context.Context, deleteDocumentOptions *DeleteDocumentOptions) (response *core.DetailedResponse, err error)

DeleteDocumentWithContext is an alternate form of the DeleteDocument method which supports a Context parameter

func (*LanguageTranslatorV3) DeleteModel

func (languageTranslator *LanguageTranslatorV3) DeleteModel(deleteModelOptions *DeleteModelOptions) (result *DeleteModelResult, response *core.DetailedResponse, err error)

DeleteModel : Delete model Deletes a custom translation model.

func (*LanguageTranslatorV3) DeleteModelWithContext

func (languageTranslator *LanguageTranslatorV3) DeleteModelWithContext(ctx context.Context, deleteModelOptions *DeleteModelOptions) (result *DeleteModelResult, response *core.DetailedResponse, err error)

DeleteModelWithContext is an alternate form of the DeleteModel method which supports a Context parameter

func (*LanguageTranslatorV3) DisableRetries

func (languageTranslator *LanguageTranslatorV3) DisableRetries()

DisableRetries disables automatic retries for requests invoked for this service instance.

func (*LanguageTranslatorV3) DisableSSLVerification

func (languageTranslator *LanguageTranslatorV3) DisableSSLVerification()

DisableSSLVerification bypasses verification of the server's SSL certificate

func (*LanguageTranslatorV3) EnableRetries

func (languageTranslator *LanguageTranslatorV3) EnableRetries(maxRetries int, maxRetryInterval time.Duration)

EnableRetries enables automatic retries for requests invoked for this service instance. If either parameter is specified as 0, then a default value is used instead.

func (*LanguageTranslatorV3) GetDocumentStatus

func (languageTranslator *LanguageTranslatorV3) GetDocumentStatus(getDocumentStatusOptions *GetDocumentStatusOptions) (result *DocumentStatus, response *core.DetailedResponse, err error)

GetDocumentStatus : Get document status Gets the translation status of a document.

func (*LanguageTranslatorV3) GetDocumentStatusWithContext

func (languageTranslator *LanguageTranslatorV3) GetDocumentStatusWithContext(ctx context.Context, getDocumentStatusOptions *GetDocumentStatusOptions) (result *DocumentStatus, response *core.DetailedResponse, err error)

GetDocumentStatusWithContext is an alternate form of the GetDocumentStatus method which supports a Context parameter

func (*LanguageTranslatorV3) GetEnableGzipCompression

func (languageTranslator *LanguageTranslatorV3) GetEnableGzipCompression() bool

GetEnableGzipCompression returns the service's EnableGzipCompression field

func (*LanguageTranslatorV3) GetModel

func (languageTranslator *LanguageTranslatorV3) GetModel(getModelOptions *GetModelOptions) (result *TranslationModel, response *core.DetailedResponse, err error)

GetModel : Get model details Gets information about a translation model, including training status for custom models. Use this API call to poll the status of your customization request. A successfully completed training has a status of `available`.

func (*LanguageTranslatorV3) GetModelWithContext

func (languageTranslator *LanguageTranslatorV3) GetModelWithContext(ctx context.Context, getModelOptions *GetModelOptions) (result *TranslationModel, response *core.DetailedResponse, err error)

GetModelWithContext is an alternate form of the GetModel method which supports a Context parameter

func (*LanguageTranslatorV3) GetServiceURL

func (languageTranslator *LanguageTranslatorV3) GetServiceURL() string

GetServiceURL returns the service URL

func (*LanguageTranslatorV3) GetTranslatedDocument

func (languageTranslator *LanguageTranslatorV3) GetTranslatedDocument(getTranslatedDocumentOptions *GetTranslatedDocumentOptions) (result io.ReadCloser, response *core.DetailedResponse, err error)

GetTranslatedDocument : Get translated document Gets the translated document associated with the given document ID.

func (*LanguageTranslatorV3) GetTranslatedDocumentWithContext

func (languageTranslator *LanguageTranslatorV3) GetTranslatedDocumentWithContext(ctx context.Context, getTranslatedDocumentOptions *GetTranslatedDocumentOptions) (result io.ReadCloser, response *core.DetailedResponse, err error)

GetTranslatedDocumentWithContext is an alternate form of the GetTranslatedDocument method which supports a Context parameter

func (*LanguageTranslatorV3) Identify

func (languageTranslator *LanguageTranslatorV3) Identify(identifyOptions *IdentifyOptions) (result *IdentifiedLanguages, response *core.DetailedResponse, err error)

Identify : Identify language Identifies the language of the input text.

func (*LanguageTranslatorV3) IdentifyWithContext

func (languageTranslator *LanguageTranslatorV3) IdentifyWithContext(ctx context.Context, identifyOptions *IdentifyOptions) (result *IdentifiedLanguages, response *core.DetailedResponse, err error)

IdentifyWithContext is an alternate form of the Identify method which supports a Context parameter

func (*LanguageTranslatorV3) ListDocuments

func (languageTranslator *LanguageTranslatorV3) ListDocuments(listDocumentsOptions *ListDocumentsOptions) (result *DocumentList, response *core.DetailedResponse, err error)

ListDocuments : List documents Lists documents that have been submitted for translation.

func (*LanguageTranslatorV3) ListDocumentsWithContext

func (languageTranslator *LanguageTranslatorV3) ListDocumentsWithContext(ctx context.Context, listDocumentsOptions *ListDocumentsOptions) (result *DocumentList, response *core.DetailedResponse, err error)

ListDocumentsWithContext is an alternate form of the ListDocuments method which supports a Context parameter

func (*LanguageTranslatorV3) ListIdentifiableLanguages

func (languageTranslator *LanguageTranslatorV3) ListIdentifiableLanguages(listIdentifiableLanguagesOptions *ListIdentifiableLanguagesOptions) (result *IdentifiableLanguages, response *core.DetailedResponse, err error)

ListIdentifiableLanguages : 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.

func (*LanguageTranslatorV3) ListIdentifiableLanguagesWithContext

func (languageTranslator *LanguageTranslatorV3) ListIdentifiableLanguagesWithContext(ctx context.Context, listIdentifiableLanguagesOptions *ListIdentifiableLanguagesOptions) (result *IdentifiableLanguages, response *core.DetailedResponse, err error)

ListIdentifiableLanguagesWithContext is an alternate form of the ListIdentifiableLanguages method which supports a Context parameter

func (*LanguageTranslatorV3) ListLanguages

func (languageTranslator *LanguageTranslatorV3) ListLanguages(listLanguagesOptions *ListLanguagesOptions) (result *Languages, response *core.DetailedResponse, err error)

ListLanguages : List supported languages Lists all supported languages for translation. The method returns an array of supported languages with information about each language. Languages are listed in alphabetical order by language code (for example, `af`, `ar`). In addition to basic information about each language, the response indicates whether the language is `supported_as_source` for translation and `supported_as_target` for translation. It also lists whether the language is `identifiable`.

func (*LanguageTranslatorV3) ListLanguagesWithContext

func (languageTranslator *LanguageTranslatorV3) ListLanguagesWithContext(ctx context.Context, listLanguagesOptions *ListLanguagesOptions) (result *Languages, response *core.DetailedResponse, err error)

ListLanguagesWithContext is an alternate form of the ListLanguages method which supports a Context parameter

func (*LanguageTranslatorV3) ListModels

func (languageTranslator *LanguageTranslatorV3) ListModels(listModelsOptions *ListModelsOptions) (result *TranslationModels, response *core.DetailedResponse, err error)

ListModels : List models Lists available translation models.

func (*LanguageTranslatorV3) ListModelsWithContext

func (languageTranslator *LanguageTranslatorV3) ListModelsWithContext(ctx context.Context, listModelsOptions *ListModelsOptions) (result *TranslationModels, response *core.DetailedResponse, err error)

ListModelsWithContext is an alternate form of the ListModels method which supports a Context parameter

func (*LanguageTranslatorV3) NewCreateModelOptions

func (*LanguageTranslatorV3) NewCreateModelOptions(baseModelID string) *CreateModelOptions

NewCreateModelOptions : Instantiate CreateModelOptions

func (*LanguageTranslatorV3) NewDeleteDocumentOptions

func (*LanguageTranslatorV3) NewDeleteDocumentOptions(documentID string) *DeleteDocumentOptions

NewDeleteDocumentOptions : Instantiate DeleteDocumentOptions

func (*LanguageTranslatorV3) NewDeleteModelOptions

func (*LanguageTranslatorV3) NewDeleteModelOptions(modelID string) *DeleteModelOptions

NewDeleteModelOptions : Instantiate DeleteModelOptions

func (*LanguageTranslatorV3) NewGetDocumentStatusOptions

func (*LanguageTranslatorV3) NewGetDocumentStatusOptions(documentID string) *GetDocumentStatusOptions

NewGetDocumentStatusOptions : Instantiate GetDocumentStatusOptions

func (*LanguageTranslatorV3) NewGetModelOptions

func (*LanguageTranslatorV3) NewGetModelOptions(modelID string) *GetModelOptions

NewGetModelOptions : Instantiate GetModelOptions

func (*LanguageTranslatorV3) NewGetTranslatedDocumentOptions

func (*LanguageTranslatorV3) NewGetTranslatedDocumentOptions(documentID string) *GetTranslatedDocumentOptions

NewGetTranslatedDocumentOptions : Instantiate GetTranslatedDocumentOptions

func (*LanguageTranslatorV3) NewIdentifyOptions

func (*LanguageTranslatorV3) NewIdentifyOptions(text string) *IdentifyOptions

NewIdentifyOptions : Instantiate IdentifyOptions

func (*LanguageTranslatorV3) NewListDocumentsOptions

func (*LanguageTranslatorV3) NewListDocumentsOptions() *ListDocumentsOptions

NewListDocumentsOptions : Instantiate ListDocumentsOptions

func (*LanguageTranslatorV3) NewListIdentifiableLanguagesOptions

func (*LanguageTranslatorV3) NewListIdentifiableLanguagesOptions() *ListIdentifiableLanguagesOptions

NewListIdentifiableLanguagesOptions : Instantiate ListIdentifiableLanguagesOptions

func (*LanguageTranslatorV3) NewListLanguagesOptions

func (*LanguageTranslatorV3) NewListLanguagesOptions() *ListLanguagesOptions

NewListLanguagesOptions : Instantiate ListLanguagesOptions

func (*LanguageTranslatorV3) NewListModelsOptions

func (*LanguageTranslatorV3) NewListModelsOptions() *ListModelsOptions

NewListModelsOptions : Instantiate ListModelsOptions

func (*LanguageTranslatorV3) NewTranslateDocumentOptions

func (*LanguageTranslatorV3) NewTranslateDocumentOptions(file io.ReadCloser, filename string) *TranslateDocumentOptions

NewTranslateDocumentOptions : Instantiate TranslateDocumentOptions

func (*LanguageTranslatorV3) NewTranslateOptions

func (*LanguageTranslatorV3) NewTranslateOptions(text []string) *TranslateOptions

NewTranslateOptions : Instantiate TranslateOptions

func (*LanguageTranslatorV3) SetDefaultHeaders

func (languageTranslator *LanguageTranslatorV3) SetDefaultHeaders(headers http.Header)

SetDefaultHeaders sets HTTP headers to be sent in every request

func (*LanguageTranslatorV3) SetEnableGzipCompression

func (languageTranslator *LanguageTranslatorV3) SetEnableGzipCompression(enableGzip bool)

SetEnableGzipCompression sets the service's EnableGzipCompression field

func (*LanguageTranslatorV3) SetServiceURL

func (languageTranslator *LanguageTranslatorV3) SetServiceURL(url string) error

SetServiceURL sets the service URL

func (*LanguageTranslatorV3) Translate

func (languageTranslator *LanguageTranslatorV3) Translate(translateOptions *TranslateOptions) (result *TranslationResult, response *core.DetailedResponse, err error)

Translate : Translate Translates the input text from the source language to the target language. Specify a model ID that indicates the source and target languages, or specify the source and target languages individually. You can omit the source language to have the service attempt to detect the language from the input text. If you omit the source language, the request must contain sufficient input text for the service to identify the source language.

You can translate a maximum of 50 KB (51,200 bytes) of text with a single request. All input text must be encoded in UTF-8 format.

func (*LanguageTranslatorV3) TranslateDocument

func (languageTranslator *LanguageTranslatorV3) TranslateDocument(translateDocumentOptions *TranslateDocumentOptions) (result *DocumentStatus, response *core.DetailedResponse, err error)

TranslateDocument : Translate document Submit a document for translation. You can submit the document contents in the `file` parameter, or you can reference a previously submitted document by document ID. The maximum file size for document translation is * 20 MB for service instances on the Standard, Advanced, and Premium plans * 2 MB for service instances on the Lite plan.

func (*LanguageTranslatorV3) TranslateDocumentWithContext

func (languageTranslator *LanguageTranslatorV3) TranslateDocumentWithContext(ctx context.Context, translateDocumentOptions *TranslateDocumentOptions) (result *DocumentStatus, response *core.DetailedResponse, err error)

TranslateDocumentWithContext is an alternate form of the TranslateDocument method which supports a Context parameter

func (*LanguageTranslatorV3) TranslateWithContext

func (languageTranslator *LanguageTranslatorV3) TranslateWithContext(ctx context.Context, translateOptions *TranslateOptions) (result *TranslationResult, response *core.DetailedResponse, err error)

TranslateWithContext is an alternate form of the Translate method which supports a Context parameter

type LanguageTranslatorV3Options

type LanguageTranslatorV3Options struct {
	ServiceName   string
	URL           string
	Authenticator core.Authenticator

	// Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. The current version is
	// `2018-05-01`.
	Version *string `validate:"required"`
}

LanguageTranslatorV3Options : Service options

type Languages

type Languages struct {
	// An array of supported languages with information about each language.
	Languages []Language `json:"languages" validate:"required"`
}

Languages : The response type for listing supported languages.

type ListDocumentsOptions

type ListDocumentsOptions struct {

	// Allows users to set headers on API requests
	Headers map[string]string
}

ListDocumentsOptions : The ListDocuments options.

func (*ListDocumentsOptions) SetHeaders

func (options *ListDocumentsOptions) SetHeaders(param map[string]string) *ListDocumentsOptions

SetHeaders : Allow user to set Headers

type ListIdentifiableLanguagesOptions

type ListIdentifiableLanguagesOptions struct {

	// Allows users to set headers on API requests
	Headers map[string]string
}

ListIdentifiableLanguagesOptions : The ListIdentifiableLanguages options.

func (*ListIdentifiableLanguagesOptions) SetHeaders

SetHeaders : Allow user to set Headers

type ListLanguagesOptions

type ListLanguagesOptions struct {

	// Allows users to set headers on API requests
	Headers map[string]string
}

ListLanguagesOptions : The ListLanguages options.

func (*ListLanguagesOptions) SetHeaders

func (options *ListLanguagesOptions) SetHeaders(param map[string]string) *ListLanguagesOptions

SetHeaders : Allow user to set Headers

type ListModelsOptions

type ListModelsOptions struct {
	// Specify a language code to filter results by source language.
	Source *string `json:"source,omitempty"`

	// Specify a language code to filter results by target language.
	Target *string `json:"target,omitempty"`

	// If the `default` parameter isn't specified, the service returns all models (default and non-default) for each
	// language pair. To return only default models, set this parameter to `true`. To return only non-default models, set
	// this parameter to `false`. There is exactly one default model, the IBM-provided base model, per language pair.
	Default *bool `json:"default,omitempty"`

	// Allows users to set headers on API requests
	Headers map[string]string
}

ListModelsOptions : The ListModels options.

func (*ListModelsOptions) SetDefault

func (_options *ListModelsOptions) SetDefault(defaultVar bool) *ListModelsOptions

SetDefault : Allow user to set Default

func (*ListModelsOptions) SetHeaders

func (options *ListModelsOptions) SetHeaders(param map[string]string) *ListModelsOptions

SetHeaders : Allow user to set Headers

func (*ListModelsOptions) SetSource

func (_options *ListModelsOptions) SetSource(source string) *ListModelsOptions

SetSource : Allow user to set Source

func (*ListModelsOptions) SetTarget

func (_options *ListModelsOptions) SetTarget(target string) *ListModelsOptions

SetTarget : Allow user to set Target

type TranslateDocumentOptions

type TranslateDocumentOptions struct {
	// The contents of the source file to translate. The maximum file size for document translation is 20 MB for service
	// instances on the Standard, Advanced, and Premium plans, and 2 MB for service instances on the Lite plan. For more
	// information, see [Supported file formats
	// (Beta)](https://cloud.ibm.com/docs/language-translator?topic=language-translator-document-translator-tutorial#supported-file-formats).
	File io.ReadCloser `json:"file" validate:"required"`

	// The filename for file.
	Filename *string `json:"filename" validate:"required"`

	// The content type of file.
	FileContentType *string `json:"file_content_type,omitempty"`

	// The model to use for translation. For example, `en-de` selects the IBM-provided base model for English-to-German
	// translation. A model ID overrides the `source` and `target` parameters and is required if you use a custom model. If
	// no model ID is specified, you must specify at least a target language.
	ModelID *string `json:"model_id,omitempty"`

	// Language code that specifies the language of the source document. If omitted, the service derives the source
	// language from the input text. The input must contain sufficient text for the service to identify the language
	// reliably.
	Source *string `json:"source,omitempty"`

	// Language code that specifies the target language for translation. Required if model ID is not specified.
	Target *string `json:"target,omitempty"`

	// To use a previously submitted document as the source for a new translation, enter the `document_id` of the document.
	DocumentID *string `json:"document_id,omitempty"`

	// Allows users to set headers on API requests
	Headers map[string]string
}

TranslateDocumentOptions : The TranslateDocument options.

func (*TranslateDocumentOptions) SetDocumentID

func (_options *TranslateDocumentOptions) SetDocumentID(documentID string) *TranslateDocumentOptions

SetDocumentID : Allow user to set DocumentID

func (*TranslateDocumentOptions) SetFile

SetFile : Allow user to set File

func (*TranslateDocumentOptions) SetFileContentType

func (_options *TranslateDocumentOptions) SetFileContentType(fileContentType string) *TranslateDocumentOptions

SetFileContentType : Allow user to set FileContentType

func (*TranslateDocumentOptions) SetFilename

func (_options *TranslateDocumentOptions) SetFilename(filename string) *TranslateDocumentOptions

SetFilename : Allow user to set Filename

func (*TranslateDocumentOptions) SetHeaders

func (options *TranslateDocumentOptions) SetHeaders(param map[string]string) *TranslateDocumentOptions

SetHeaders : Allow user to set Headers

func (*TranslateDocumentOptions) SetModelID

func (_options *TranslateDocumentOptions) SetModelID(modelID string) *TranslateDocumentOptions

SetModelID : Allow user to set ModelID

func (*TranslateDocumentOptions) SetSource

func (_options *TranslateDocumentOptions) SetSource(source string) *TranslateDocumentOptions

SetSource : Allow user to set Source

func (*TranslateDocumentOptions) SetTarget

func (_options *TranslateDocumentOptions) SetTarget(target string) *TranslateDocumentOptions

SetTarget : Allow user to set Target

type TranslateOptions

type TranslateOptions struct {
	// Input text in UTF-8 encoding. Submit a maximum of 50 KB (51,200 bytes) of text with a single request. Multiple
	// elements result in multiple translations in the response.
	Text []string `json:"text" validate:"required"`

	// The model to use for translation. For example, `en-de` selects the IBM-provided base model for English-to-German
	// translation. A model ID overrides the `source` and `target` parameters and is required if you use a custom model. If
	// no model ID is specified, you must specify at least a target language.
	ModelID *string `json:"model_id,omitempty"`

	// Language code that specifies the language of the input text. If omitted, the service derives the source language
	// from the input text. The input must contain sufficient text for the service to identify the language reliably.
	Source *string `json:"source,omitempty"`

	// Language code that specifies the target language for translation. Required if model ID is not specified.
	Target *string `json:"target,omitempty"`

	// Allows users to set headers on API requests
	Headers map[string]string
}

TranslateOptions : The Translate options.

func (*TranslateOptions) SetHeaders

func (options *TranslateOptions) SetHeaders(param map[string]string) *TranslateOptions

SetHeaders : Allow user to set Headers

func (*TranslateOptions) SetModelID

func (_options *TranslateOptions) SetModelID(modelID string) *TranslateOptions

SetModelID : Allow user to set ModelID

func (*TranslateOptions) SetSource

func (_options *TranslateOptions) SetSource(source string) *TranslateOptions

SetSource : Allow user to set Source

func (*TranslateOptions) SetTarget

func (_options *TranslateOptions) SetTarget(target string) *TranslateOptions

SetTarget : Allow user to set Target

func (*TranslateOptions) SetText

func (_options *TranslateOptions) SetText(text []string) *TranslateOptions

SetText : Allow user to set Text

type Translation

type Translation struct {
	// Translation output in UTF-8.
	Translation *string `json:"translation" validate:"required"`
}

Translation : Translation struct

type TranslationModel

type TranslationModel struct {
	// A globally unique string that identifies the underlying model that is used for translation.
	ModelID *string `json:"model_id" validate:"required"`

	// Optional name that can be specified when the model is created.
	Name *string `json:"name,omitempty"`

	// Translation source language code.
	Source *string `json:"source,omitempty"`

	// Translation target language code.
	Target *string `json:"target,omitempty"`

	// Model ID of the base model that was used to customize the model. If the model is not a custom model, this will be an
	// empty string.
	BaseModelID *string `json:"base_model_id,omitempty"`

	// The domain of the translation model.
	Domain *string `json:"domain,omitempty"`

	// Whether this model can be used as a base for customization. Customized models are not further customizable, and some
	// base models are not customizable.
	Customizable *bool `json:"customizable,omitempty"`

	// Whether or not the model is a default model. A default model is the model for a given language pair that will be
	// used when that language pair is specified in the source and target parameters.
	DefaultModel *bool `json:"default_model,omitempty"`

	// Either an empty string, indicating the model is not a custom model, or the ID of the service instance that created
	// the model.
	Owner *string `json:"owner,omitempty"`

	// Availability of a model.
	Status *string `json:"status,omitempty"`
}

TranslationModel : Response payload for models.

type TranslationModels

type TranslationModels struct {
	// An array of available models.
	Models []TranslationModel `json:"models" validate:"required"`
}

TranslationModels : The response type for listing existing translation models.

type TranslationResult

type TranslationResult struct {
	// An estimate of the number of words in the input text.
	WordCount *int64 `json:"word_count" validate:"required"`

	// Number of characters in the input text.
	CharacterCount *int64 `json:"character_count" validate:"required"`

	// The language code of the source text if the source language was automatically detected.
	DetectedLanguage *string `json:"detected_language,omitempty"`

	// A score between 0 and 1 indicating the confidence of source language detection. A higher value indicates greater
	// confidence. This is returned only when the service automatically detects the source language.
	DetectedLanguageConfidence *float64 `json:"detected_language_confidence,omitempty"`

	// List of translation output in UTF-8, corresponding to the input text entries.
	Translations []Translation `json:"translations" validate:"required"`
}

TranslationResult : TranslationResult struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL