Show / Hide Table of Contents

Cloud Operations

This section contains the Cloud specific setup and operations.

Building the CloudLanguageWeaverClient

Using default configuration:

try (CloudLanguageWeaverClient cloudLanguageWeaverClient = new CloudLanguageWeaverClient()
       .build()) {
    // perform requests
}
Note

The default setup is the following:

  • Europe region
  • API credentials loaded from environment variables
  • Default retry mechanism (retry up to 3 times, with a delay of 5 seconds)

Using custom configuration:

ClientConfiguration clientConfiguration = new ClientConfiguration()
        .setCredentialsConfiguration(new CredentialsConfiguration("clientId", "clientSecret"))
        .setRetryConfiguration(new RetryConfiguration()
                .setAttempts(3)
                .setDelay(5)
                .setUnit(TimeUnit.SECONDS));

try (CloudLanguageWeaverClient cloudLanguageWeaverClient = new CloudLanguageWeaverClient()
        .withConfigurations(clientConfiguration)
        .setRegion(Regions.US)
        .build()) {
    // perform requests
}

See API credentials and ClientConfiguration setup.
See API URL setup.

Get all Language Pairs

By using the getCloudLanguagePairs method from CloudLanguageWeaverClient, the list of available language pairs will be returned, corresponding to the given client identifier. These will be used for translation requests.

    try (CloudLanguageWeaverClient lwClient = new CloudLanguageWeaverClient().build()) {
        final CloudLanguagePairsResult languagePairsResult = lwClient.getCloudLanguagePairs();
        // handle result
    }

See the complete sample on GitHub.

The CloudLanguagePairsResult object contains the following information:

Name Type Description
accountId integer Account identifier
languagePairs array Contains a list of CloudLanguagePair objects

The CloudLanguagePair object contains the following information:

Name Type Description
name string Language pair name
displayName string Language pair display name
sourceLanguageId string Three letters language code of the source language
targetLanguageId string Three letters language code of the target language
model string A string representing a unique identifier for the language pair combination sourceLanguageId-targetLanguageId-model. (e.g. generic)

For more information about the API, access: Get all Language Pairs.

Get all Linguistic Options for a Language Pair

By using the getCloudLinguisticOptions method from CloudLanguageWeaverClient, the list of available linguistic options of a specific language pair will be returned, corresponding to the given client identifier. These will be used for translation requests.

        try (CloudLanguageWeaverClient lwClient = new CloudLanguageWeaverClient().build()) {
            CloudGetLinguisticOptionsRequest cloudGetLinguisticOptionsRequest= new CloudGetLinguisticOptionsRequest()
                .setSourceLanguageId("chi")
                .setTargetLanguageId("eng")
                .setModel("generic");

            final CloudLinguisticOptionsResult cloudLinguisticOptionsResult = lwClient.getCloudLinguisticOptions(cloudGetLinguisticOptionsRequest);
            // handle result
        }

See the complete sample on GitHub.

The CloudGetLinguisticOptionsRequest object contains the following information:

Name Type Mandatory Default value Description
sourceLanguageId string yes Three letters language code of the source language
targetLanguageId string yes Three letters language code of the target language
model string yes A string representing a unique identifier for the language pair combination sourceLanguageId-targetLanguageId-model. (e.g. generic)

The CloudGetLinguisticOptionsRequest object can be obtained from an existing CloudLanguagePair object as well using the toGetLinguisticOptionsRequest() method:

CloudGetLinguisticOptionsRequest cloudGetLinguisticOptionsRequest = languagePair.toGetLinguisticOptionsRequest();

The CloudLinguisticOptionsResult object contains the following information:

Name Type Description
linguisticOptions CloudLinguisticOption array List of linguistic options available for the requested language pair

The CloudLinguisticOption object contains the following information:

Name Type Description
name string Linguistic option name
id string Linguistic option identifier
systemDefault string System default linguistic option
accountDefault string Account default linguistic option. Field missing when there is no account default
values string array Available values for the current linguistic option

For more information about the API, access: Get all Linguistic Options for a language pair.

Get all Dictionaries

By using the getCloudDictionaries method from CloudLanguageWeaverClient, the list of available dictionaries will be returned, corresponding to the given client identifier. These can be used for translation requests.

    try (CloudLanguageWeaverClient lwClient = new CloudLanguageWeaverClient().build()) {
        final CloudDictionariesResult dictionariesResult = lwClient.getCloudDictionaries(1);
        // handle result
    }

See the complete sample on GitHub.

The getCloudDictionaries method has the following parameters:

Name Type Mandatory Default Description
pageNumber number yes Number specifying the requested page number
pageSize number no 100 Number specifying the requested page size

The CloudDictionariesResult object contains the following information:

Name Type Description
accountId integer Account identifier
dictionaries array Contains a list of CloudDictionary objects

The CloudDictionary object contains the following information:

Name Type Description
accountId integer Unique numeric identifier for the account associated to the dictionary
dictionaryId string Dictionary identifier
name string Name of the dictionary
description string Description for the dictionary
source string Three letters language code of the source language for the dictionary
target string Three letters language code of the target language for the dictionary
createdBy string The email of the user that created the dictionary
creationDate string Date when the dictionary was created
lastModifiedBy string The email of the user that last modified the dictionary
lastModifyDate string Date when the dictionary was last modified

For more information about the API, access: Get all Dictionaries.

Translations

Perform a Text Translation

The translateText method from CloudLanguageWeaverClient, performs a text translation using a required CloudTranslateTextRequest object.

    try (CloudLanguageWeaverClient lwClient = new CloudLanguageWeaverClient().build()) {
        CloudTranslateTextRequest translateTextRequest = new CloudTranslateTextRequest()
                .setSourceLanguageId("eng")
                .setTargetLanguageId("fra")
                .setModel("generic")
                .addInput("The weather is wonderful today!")
                .addInput("This is a new input that is part of an array translation.")
                .setInputFormat(Format.PLAIN)
                .addDictionary("e929ec5e-4f9c-43b1-8b1d-e48742f396d0")
                .addDictionary("0116ba95-8451-4cb2-ab6a-5e94334434d1");
        final CloudTranslationTextResult translateTextResult = lwClient.translateText(translateTextRequest);

        System.out.println(translateTextResult.getTranslation());
    }

See the complete sample on GitHub.

The CloudTranslateTextRequest object contains the following information:

Name Type Mandatory Default value Description
sourceLanguageId string yes Three letters language code of the source language or auto which signals that the source language should be auto detected
targetLanguageId string yes Three letters language code of the target language
model string no* See notes below A string representing a unique identifier for the language pair combination sourceLanguageId-targetLanguageId-model. (e.g. generic)
inputFormat Format no PLAIN Format of input content. See Input Formats.
input string array yes Content to be translated. Input is added using the addInput method. This can be called multiple times in order to perform array translations.
dictionaries string array no empty A string array containing dictionary ids. Dictionaries are added using the addDictionary method. This can be called multiple times if multiple dictionaries need to be used in a translation.
linguisticOptions map of strings no Map of strings containing pairs of linguistic option name and value. Values are case sensitive. You can only use the linguistic options that are available for that specific language pair. You can see what linguistic options are available for a language pair using this method call: Linguistic Options
Note

In order to use Linguistic Options feature you must enable it in your account

Text Input formats

Name Description
HTML HTML
PLAIN Plain text (UTF8)
XLINE Plain text, one sentence per line
TMX Translation Memory eXchange
XLIFF XML Localization Interchange File Format
BCM Proprietary format
XML Extensible Markup Language
SDLXML Treats every closing XML tag in the input as the end of a segment. The XML format in contrast does not make this assumption.
Note

sourceLanguageId, targetLanguageId, model - can be used in the following combinations:

  • sourceLanguageId=[languageName] and targetLanguageId=[languageName] and model=[identifier for the language pair] - when all three are used they uniquely identify a language pair e.g: Eng-Fra-generic
  • sourceLanguageId=auto, targetLanguageId=[languageName], model- will be ignored even if specified - A language pair that matches the detected source language and the specified target language will be automatically selected. The selected language pair will be the first one (in alphabetical order) available in your account that matches the selection. E.g. if the detected source language is eng and the target language is fra and your account has subscriptions to (EngFra-Generic, EngFra-Sports, EngFra-Sports123) the language pair selected will be EngFra-Generic.

The CloudTranslationTextResult object contains the following information:

Name Type Description
translation string array Array containing the translated content corresponding to the given input
requestId string Translation request identifier
inputFormat Format Format of input content
outputFormat Format Format of output content
sourceLanguageId string Three letters language code of the source language
targetLanguageId string Three letters language code of the target language
model string String representing a unique identifier for the language pair combination sourceLanguageId-targetLanguageId-model. (e.g. generic)
translationStats object TranslationStatistics object

The TranslationStatistics object contains the following information:

Name Type Description
inputWordCount long Number of input words in the source translated
inputCharCount long Number of input characters in the source translated
inputByteCount long Number of input bytes in the source translated
translationWordCount long Number of output words in the source translated
translationCharCount long Number of output characters in the source translated
translationByteCount long Number of output bytes in the source translated

For more information about the API, access: Text Translations.

Perform a File Translation

The translateFile method from CloudLanguageWeaverClient, performs a file translation using a required CloudTranslateFileRequest object.

    try (CloudLanguageWeaverClient lwClient = new CloudLanguageWeaverClient().build()) {
        CloudTranslateFileRequest translateFileRequest = new CloudTranslateFileRequest()
                .setSourceLanguageId("eng")
                .setTargetLanguageId("fra")
                .setModel("generic")
                .setInputFormat(Format.PLAIN)
                // provide full path to the source file
                .setInputFile(Paths.get("java", "src", "main", "resources", "input", "input1.txt").toFile().getAbsolutePath())
                .setOutputFile(Paths.get("java", "src", "main", "resources", "output").toFile().getAbsolutePath() + File.separator + "input1-translated.txt")
                .addDictionary("e929ec5e-4f9c-43b1-8b1d-e48742f396d0")
                .addDictionary("0116ba95-8451-4cb2-ab6a-5e94334434d1");

        final CloudTranslationFileResult translateFile = lwClient.translateFile(translateFileRequest);
        // handle result if outputFile not specified
    }

See the complete sample on GitHub.

The CloudTranslateFileRequest object contains the following information:

Name Type Mandatory Default value Description
sourceLanguageId string yes Three letters language code of the source language or auto which signals that the source language should be auto detected
targetLanguageId string yes Three letters language code of the target language
model string no* See notes below A string representing a unique identifier for the language pair combination sourceLanguageId-targetLanguageId-model. (e.g. generic)
inputFormat Format no PLAIN Format of input content. See Input Formats.
inputFile string yes The path for the input file that needs to be translated
outputFile string no The path for the output file that will contain the translated content. If the outputFile is not provided, the translated content will be returned as part of the TranslationFileResult as an InputStream
dictionaries string array no empty A string array containing dictionary ids. Dictionaries are added using the addDictionary method. This can be called multiple times if multiple dictionaries need to be used in a translation.
pdfConverter PdfConverter no STANDARD An enum representing one of the three supported options for the pdf converter: SMART_SELECTION, ABBYY and STANDARD. ABBYY is used with better results for scanned PDFs. With SMART_SELECTION Language Weaver will choose the best pdf converter option for given input, the choice will be made between ABBYY and STANDARD.
linguisticOptions map of strings no Map of strings containing pairs of linguistic option name and value. Values are case sensitive. You can only use the linguistic options that are available for that specific language pair. You can see what linguistic options are available for a language pair using this method call: Linguistic Options
Note

In order to use Linguistic Options feature you must enable it in your account

Note

sourceLanguageId, targetLanguageId, model - can be used in the following combinations:

  • sourceLanguageId=[languageName] and targetLanguageId=[languageName] and model=[identifier for the language pair] - when all three are used they uniquely identify a language pair e.g: Eng-Fra-generic
  • sourceLanguageId=auto, targetLanguageId=[languageName], model- will be ignored even if specified - A language pair that matches the detected source language and the specified target language will be automatically selected. The selected language pair will be the first one (in alphabetical order) available in your account that matches the selection. E.g. if the detected source language is eng and the target language is fra and your account has subscriptions to (EngFra-Generic, EngFra-Sports, EngFra-Sports123) the language pair selected will be EngFra-Generic.
Note
  • For image input formats, output format is PLAIN text (.txt)
  • For EML and MSG input formats, output format is PLAIN text (.txt)
  • For PDF input format, output format is DOCX (.docx)
  • For all other input formats, output format is the same as the input format

The CloudTranslationFileResult object contains the following information:

Name Type Description
fileContent InputStream InputStream representing the translated file content. This is populated when the translated content is not stored in an output file on the disk, based on the outputFile value.
requestId string Translation request identifier
inputFormat Format Format of input content
outputFormat Format Format of output content
sourceLanguageId string Three letters language code of the source language
targetLanguageId string Three letters language code of the target language
model string String representing a unique identifier for the language pair combination sourceLanguageId-targetLanguageId-model. (e.g. generic)
translationStats object TranslationStatistics object

The TranslationStatistics object contains the following information:

Name Type Description
inputWordCount long Number of input words in the source translated
inputCharCount long Number of input characters in the source translated
inputByteCount long Number of input bytes in the source translated
translationWordCount long Number of output words in the source translated
translationCharCount long Number of output characters in the source translated
translationByteCount long Number of output bytes in the source translated

For more information about the API, access: File Translations.

Perform a Batch File Translation

The translateBatchFile method from CloudLanguageWeaverClient, performs a batch file translation using a required CloudTranslateBatchFileRequest object.

    try (CloudLanguageWeaverClient lwClient = new CloudLanguageWeaverClient().build()) {
        CloudTranslateBatchFileRequest translateFileRequest = new CloudTranslateBatchFileRequest()
                .setSourceLanguageId("eng")
                .setTargetLanguageId("fra")
                .setModel("generic")
                .addDictionary("e929ec5e-4f9c-43b1-8b1d-e48742f396d0")
                .addDictionary("0116ba95-8451-4cb2-ab6a-5e94334434d1")
                // provide full path to the input and output folders
                .setInputBatchFolderPath(Paths.get("java", "src", "main", "resources", "input").toFile().getAbsolutePath())
                .setOutputBatchFolderPath(Paths.get("java", "src", "main", "resources", "output").toFile().getAbsolutePath());

        lwClient.translateBatchFile(translateFileRequest);
    }

See the complete sample on GitHub.

The CloudTranslateBatchFileRequest object contains the following information:

Name Type Mandatory Default value Description
sourceLanguageId string yes Three letters language code of the source language or auto which signals that the source language should be auto detected
targetLanguageId string yes Three letters language code of the target language
model string no* See notes below A string representing a unique identifier for the language pair combination sourceLanguageId-targetLanguageId-model. (e.g. generic)
inputBatchPath string yes The path to the folder that contains the input files
outputBatchPath string yes The path to the folder where the corresponding translated files will be added
dictionaries string array no empty A string array containing dictionary ids. Dictionaries are added using the addDictionary method. This can be called multiple times if multiple dictionaries need to be used in a translation.
pdfConverter PdfConverter no STANDARD An enum representing one of the three supported options for the pdf converter: SMART_SELECTION, ABBYY and STANDARD. ABBYY is used with better results for scanned PDFs. With SMART_SELECTION Language Weaver will choose the best pdf converter option for given input, the choice will be made between ABBYY and STANDARD.
linguisticOptions map of strings no Map of strings containing pairs of linguistic option name and value. Values are case sensitive. You can only use the linguistic options that are available for that specific language pair. You can see what linguistic options are available for a language pair using this method call: Linguistic Options
Note

In order to use Linguistic Options feature you must enable it in your account

Note

sourceLanguageId, targetLanguageId, model - can be used in the following combinations:

  • sourceLanguageId=[languageName] and targetLanguageId=[languageName] and model=[identifier for the language pair] - when all three are used they uniquely identify a language pair e.g: Eng-Fra-generic
  • sourceLanguageId=auto, targetLanguageId=[languageName], model- will be ignored even if specified - A language pair that matches the detected source language and the specified target language will be automatically selected. The selected language pair will be the first one (in alphabetical order) available in your account that matches the selection. E.g. if the detected source language is eng and the target language is fra and your account has subscriptions to (EngFra-Generic, EngFra-Sports, EngFra-Sports123) the language pair selected will be EngFra-Generic.
Note
  • For image input formats, output format is PLAIN text (.txt)
  • For EML and MSG input formats, output format is PLAIN text (.txt)
  • For PDF input format, output format is DOCX (.docx)
  • For all other input formats, output format is the same as the input format

For more information about the API, access: File Translations.

Content Insights

Create Content Insights

The getContentInsights method from CloudLanguageWeaverClient creates Content Insights using a required CloudFileContentInsightsRequest object.

    try (CloudLanguageWeaverClient lwClient = new CloudLanguageWeaverClient().build()){
        CloudFileContentInsightsRequest contentInsightsRequest = new CloudFileContentInsightsRequest()
            .setSourceLanguage("eng")
            .setFile(Paths.get("java", "src", "main", "resources", "input", "input1.txt").toFile().getAbsolutePath());

        final CloudContentInsightsResult cloudContentInsightsResult = lwClient.getContentInsights(contentInsightsRequest);
        // handle result
    }

See the complete sample on GitHub.

The CloudFileContentInsightsRequest object contains the following information:

Name Type Mandatory Default
value
Description
sourceLanguage string yes Three letters language code of the source language
file string yes The full path of the source file

The CloudContentInsightsResult object contains the following information:

Name Type Description
contentInsightsId string The id of the content insights request. This has to be used for the subsequent calls
sourceLanguage string Three letters language code of the source language
stats CloudContentInsightsStatistics Object containing the number of input words in the source files and the number of input characters in the source files
summarization CloudSummarization Object containing the sentences from the input files that were selected as part of the summary

The CloudContentInsightsStatistics object contains the following information:

Name Type Description
inputWordCount int Number of input words in the source translated
inputCharCount int Number of input characters in the source translated

The CloudSummarization object contains the following information:

Name Type Description
segments CloudSegment array The array with the sentences from the input files that were selected as part of the summary

The CloudSegment object contains the following information:

Name Type Description
text string A sentence from the input files that was selected to be part of the summary
lineNumber int The line number of the sentence in the input file
score float A score between 0 and 1. The higher the score, the more representative the sentence is for the summary

For more information about the API, access: Content Insights.

Create Content Insights for existing Translations

The getContentInsightsForTranslations method from CloudLanguageWeaverClient performs content insights for existing translations using a required translationIds list.

    try (CloudLanguageWeaverClient lwClient = new CloudLanguageWeaverClient().build()){
        CloudTranslateFileRequest translateFileRequest = new CloudTranslateFileRequest()
            .setSourceLanguageId("eng")
            .setTargetLanguageId("fra")
            .setModel("generic")
            .setInputFormat("plain")
            // provide full path to the source file
            .setInputFile(Paths.get("java", "src", "main", "resources", "input", "input1.txt").toFile().getAbsolutePath())
            .setOutputFile(Paths.get("java", "src", "main", "resources", "output").toFile().getAbsolutePath() + File.separator + "input1-translated.txt")
            .addDictionary("e929ec5e-4f9c-43b1-8b1d-e48742f396d0")
            .addDictionary("0116ba95-8451-4cb2-ab6a-5e94334434d1");

        CloudContentInsightsRequest cloudContentInsightsRequest = new CloudContentInsightsRequest()
            .addTranslationId(lwClient.translateFile(translateFileRequest).getTranslationId());

        final CloudContentInsightsResult cloudContentInsightsResult = lwClient.getContentInsightsForTranslations(contentInsightsForTranslationsRequest);
        // handle result
        }

See the complete sample on GitHub.

Note

When you perform content insights for existing translation, you need to disable "Content deletion" and enable "Content Insights" from your account settings

The CloudContentInsightsRequest object contains the following information:

Name Type Mandatory Default value Description
translationIds string array no empty A string array containing translation ids

The CloudContentInsightsResult object contains the following information:

Name Type Description
contentInsightsId string The id of the content insights request. This has to be used for the subsequent calls
sourceLanguage string Three letters language code of the source language
stats CloudContentInsightsStatistics Object containing the number of input words in the source files and the number of input characters in the source files
summarization CloudSummarization Object containing the sentences from the input files that were selected as part of the summary

The CloudContentInsightsStatistics object contains the following information:

Name Type Description
inputWordCount int Number of input words in the source translated
inputCharCount int Number of input characters in the source translated

The CloudSummarization object contains the following information:

Name Type Description
segments CloudSegment array The array with the sentences from the input files that were selected as part of the summary

The CloudSegment object contains the following information:

Name Type Description
text string A sentence from the input files that was selected to be part of the summary
lineNumber int The line number of the sentence in the input file
score float A score between 0 and 1. The higher the score, the more representative the sentence is for the summary

For more information about the API, access: Content Insights For Existing Translations.

Feedback Management

Create Feedback

The createFeedback method from CloudLanguageWeaverClient creates a translation feedback using a required CloudCreateFeedbackRequest object.

    CloudCreateFeedbackRequest createFeedbackRequest = new CloudCreateFeedbackRequest()
        .setSourceLanguageId("eng")
        .setTargetLanguageId("fra")
        .setModel("generic")
        .setSourceText("sourceText")
        .setTargetText("targetText")
        .setSuggestedTranslation("suggestedTranslation")
        .setRating(3)
        .addComment(FeedbackComment.SPELLING)
        .addComment("custom comment")
        .setTranslationMetadata("metadata")
        .setNumberOfSegments(1)
        .setQualityEstimationMT(QualityEstimation.ADEQUATE)
        .setQualityEstimationMT(QualityEstimation.POOR);

    CloudFeedbackResult feedback = lwClient.createFeedback(createFeedbackRequest);

See the complete feedback samples on GitHub .

The CloudCreateFeedbackRequest object contains the following information:

Name Type Mandatory Default value Description
sourceLanguageId string yes Three letters language code of the source language
targetLanguageId string yes Three letters language code of the target language
model string yes A string representing a unique identifier for the language pair combination sourceLanguageId-targetLanguageId-model. (e.g. generic)
sourceText string yes Text provided to be translated
targetText string yes Translation provided by machine translation
suggestedTranslation string yes Expected translation
rating integer no A score from 1 to 5 representing the quality of the translation
comments array no An array of string comments about the translation. Comments can be added using the addComment method which takes as argument either a string or a FeedbackComment enum which compiles some predefined comments.
translationMetadata string no Metadata about translation (e.g. source file name)
numberOfSegments integer no 1 Positive integer which represents number of segments for translation
qualityEstimationMT QualityEstimation no The quality estimation provided by machine translation (GOOD, ADEQUATE, POOR)
qualityEstimation QualityEstimation no Expected quality estimation (GOOD, ADEQUATE, POOR)

Feedback Comments

Name Value
WORDS_OMISSION Words omission
WORDS_ADDITION Words addition
CAPITALIZATION_PUNCTUATION Capitalization, punctuation
UNINTELLIGIBLE Unintelligible
GRAMMAR Grammar
SPELLING Spelling
WORD_CHOICE Word choice

The CloudFeedbackResult object contains the following information:

Name Type Description
feedbackId string Feedback identifier
sourceLanguageId string Three letters language code of the source language
targetLanguageId string Three letters language code of the target language
model string A string representing a unique identifier for the language pair combination sourceLanguageId-targetLanguageId-model. (e.g. generic)
sourceText string Text provided to be translated
targetText string Translation provided by machine translation
suggestedTranslation string Expected translation
ratingScore integer A score from 1 to 5 representing the quality of the translation
comments array An array of string comments about translation
translationMetadata string Metadata about translation (e.g. source file name)
numberOfSegments integer Positive integer which represents number of segments for translation
qualityEstimationMT QualityEstimation The quality estimation provided by machine translation (GOOD, ADEQUATE, POOR)
qualityEstimation QualityEstimation Expected quality estimation (GOOD, ADEQUATE, POOR)
approvalState ApprovalStatus The approval status of the feedback (APPROVED, REJECTED, PENDING)
feedbackAuditData CloudAuditData Object containing details about the lifecycle of the feedback
approvalAuditData CloudAuditData Object containing details about the lifecycle of the feedback's approval

The CloudAuditData object contains the following information:

Name Type Description
createdByAccountId integer The id of the account which created the feedback
createdByUserId integer The id of the user who created the feedback
createdByUserEmail string The email of the user who created the feedback
createdByClientId string The client id which created the feedback
creationDate string Creation date of the feedback
lastModifiedByAccountId integer The id of the account which last modified the feedback
lastModifiedByUserId integer The id of the user who last modified the feedback
lastModifiedByUserEmail string The email of the user who last modified the feedback
lastModifiedByClientId string The client id which last modified the feedback
lastModifyDate string The date when the feedback was last modified

For more information about the API, access: Feedback operations.

Update Feedback

The updateFeedback method from CloudLanguageWeaverClient updates a translation feedback using a required CloudUpdateFeedbackRequest object.

    CloudUpdateFeedbackRequest cloudUpdateFeedbackRequest = new CloudUpdateFeedbackRequest()
        .setFeedbackId("feedbackId")
        .setSuggestedTranslation("new suggested translation")
        .setRating(2)
        .setQualityEstimation(QualityEstimation.POOR)
        .addComment(FeedbackComment.CAPITALIZATION_PUNCTUATION);

    CloudFeedbackResult feedback = lwClient.updateFeedback(cloudUpdateFeedbackRequest);

You can also obtain CloudUpdateFeedbackRequest from CloudFeedbackResult using the toUpdateRequest method which will transfer the feedback's updatable information into a new update request.

    CloudUpdateFeedbackRequest cloudUpdateFeedbackRequest = feedback.toUpdateRequest();

See the complete feedback samples on GitHub .

The CloudUpdateFeedbackRequest object contains the following information:

Name Type Mandatory Default value Description
feedbackId string yes The id of the feedback to be updated
suggestedTranslation string no Expected translation
rating integer no A score from 1 to 5 representing the quality of the translation
comments array no An array of string comments about the translation. Comments can be added using the addComment method which takes as argument either a string or a FeedbackComment enum which compiles some predefined comments. The CloudUpdateFeedbackRequest object also features a clearComments method which will remove the current comments assigned to the feedback.
qualityEstimation QualityEstimation no Expected quality estimation (GOOD, ADEQUATE, POOR)

The method returns a CloudFeedbackResult object which is described here.

For more information about the API, access: Feedback operations.

Update Feedback Approval Status

The updateFeedbackApproval method from CloudLanguageWeaverClient can be used to update the approval status of an existing translation feedback using a required CloudUpdateFeedbackApprovalRequest object.

     CloudUpdateFeedbackApprovalRequest cloudUpdateApprovalRequest = new CloudUpdateFeedbackApprovalRequest()
        .setFeedbackId("feedbackId")
        .setApprovalStatus(ApprovalStatus.APPROVED);

     CloudFeedbackResult feedback = lwClient.updateFeedbackApproval(cloudUpdateApprovalRequest);

You can also obtain CloudUpdateFeedbackApprovalRequest from CloudFeedbackResult using the toUpdateApprovalRequest(ApprovalStatus) method which will contain the feedback's id and the requested approval status.

    CloudUpdateFeedbackApprovalRequest cloudUpdateApprovalRequest = feedback.toUpdateApprovalRequest(ApprovalStatus.APPROVED);

See the complete feedback samples on GitHub .

The CloudUpdateFeedbackApprovalRequest object contains the following information:

Name Type Mandatory Default value Description
feedbackId string yes The id of the feedback to be updated
approvalStatus ApprovalStatus yes The approval status of the feedback (APPROVED, REJECTED, PENDING)

The method returns a CloudFeedbackResult object which is described here.

For more information about the API, access: Feedback operations.

Delete Feedback

The deleteFeedback method from CloudLanguageWeaverClient can be used to delete an existing translation feedback using a required CloudDeleteFeedbackRequest object.

    CloudDeleteFeedbackRequest deleteFeedbackRequest = new CloudDeleteFeedbackRequest()
        .setFeedbackId("feedbackId");

    lwClient.deleteFeedback(deleteFeedbackRequest);

You can also obtain CloudDeleteFeedbackRequest from CloudFeedbackResult using the toDeleteRequest method which will contain the feedback's id.

    CloudDeleteFeedbackRequest deleteFeedbackRequest = feedback.toDeleteRequest();

See the complete feedback samples on GitHub .

The CloudDeleteFeedbackRequest object contains the following information:

Name Type Mandatory Default value Description
feedbackId string yes The id of the feedback to be updated

The method returns a CloudFeedbackResult object which is described here.

For more information about the API, access: Feedback operations.

Get All Feedback

By using the getCloudFeedback method from CloudLanguageWeaverClient, the list of available feedback will be returned, corresponding to the given client identifier.
The feedback can be filtered by various criteria using an CloudFilterFeedbackRequest.
This is a paginated request thus the pageNumber parameter is mandatory while the pageSize will default to 100 if not specified.

    CloudFilterFeedbackRequest filterFeedbackRequest = new CloudFilterFeedbackRequest()
        .setApprovalStatus(ApprovalStatus.APPROVED)
        .setFeedbackCategory(FeedbackCategory.IMPROVEMENT)
        .setUser("userId")
        .setStartDate("10/10/2021")
        .setEndDate("10/10/2022")
        .setSortRequest(new CloudFeedbackSortRequest()
            .setCriteria(CloudFeedbackSortCriteria.DATE)
            .setOrder(Order.DESCENDING));

    CloudFeedbackListResult feedbackList = lwClient.getCloudFeedback(filterFeedbackRequest, 1, 50);

See the complete feedback samples on GitHub .

The getCloudFeedback method has the following parameters:

Name Type Mandatory Default Description
pageNumber integer yes Number specifying the requested page number
pageSize integer no 100 Number specifying the requested page size
filterRequest CloudFilterFeedbackRequest no Object specifying the criteria by which the returned feedback to be filtered

The CloudFilterFeedbackRequest object contains the following information:

Name Type Mandatory Default Description
startDate string yes A string representing the start date for the filtered feedback in the format dd/mm/yyyy
endDate string yes A string representing the end date for the filtered feedback in the format dd/mm/yyyy
user string no The id of the user who created the feedback
feedbackId string no Feedback identifier
approvalStatus ApprovalStatus no The approval status of the feedback (APPROVED, REJECTED, PENDING)
feedbackCategory FeedbackCategory no The category of translation feedback (IMPROVEMENT, RATING)
sortRequest CloudFeedbackSortRequest no Object specifying the criteria by which the returned feedback to be sorted. If this is not specified the feedback will be sorted by the default values which can be seen bellow.

The CloudFeedbackSortRequest object contains the following information:

Name Type Mandatory Default Description
criteria CloudFeedbackSortCriteria yes DATE DATE or LP
order Order yes ASCENDING ASCENDING or DESCENDING

The CloudFeedbackListResult object contains the following information:

Name Type Description
feedbackList array Array of CloudFeedbackResult objects
pageNumber integer Number specifying the requested page number
pageSize integer Number specifying the requested page size
totalCount long Total number of filtered feedbacks for the given account

For more information about the API, access: Feedback operations.

In This Page
Back to top