Class TranslatorSplitterConfig

All Implemented Interfaces:
Labelable

public class TranslatorSplitterConfig extends BaseDocumentSplitterConfig

Translate documents using one of the supported translation API. The following lists the supported APIs, along with the required authentication properties or settings for each:

For example, the Microsoft Translation API requires a client ID and a client secret, both obtained on Microsoft Azure Marketplace with your Microsoft account.

Translated documents will have the original document language stored in a field "document.translatedFrom".

This class is not a document "splitter" per se, but like regular splitters, the translation will create children documents for each translation performed. The parent document will always remain the original document, while the children will always be the translations.

See Also:
  • Field Details

  • Constructor Details

    • TranslatorSplitterConfig

      public TranslatorSplitterConfig()
  • Method Details

    • setFieldMatcher

      public TranslatorSplitterConfig setFieldMatcher(TextMatcher fieldMatcher)
    • getTargetLanguages

      public List<String> getTargetLanguages()
    • setTargetLanguages

      public TranslatorSplitterConfig setTargetLanguages(List<String> targetLanguages)
    • getApi

      public String getApi()
      Supported translation service API name. One of: "microsoft", "google", "lingo24", "moses", "yandex".
      Returns:
      translation api name
    • getFieldMatcher

      public TextMatcher getFieldMatcher()
      Optional matcher of fields holding content to translate instead of document body.
      Returns:
      matcher of fields to translate
    • isIgnoreNonTranslatedFields

      public boolean isIgnoreNonTranslatedFields()
      Whether to ignore fields not translated when creating child documents. Set to true if you just want children documents to contain fields for which there was a translation (and possibly, the translated content).
      Returns:
      to ignore non translated fields
    • getSourceLanguageField

      public String getSourceLanguageField()
      The name of a field containing a value representing the original document language.
      Returns:
      field holding the document language
    • getSourceLanguage

      public String getSourceLanguage()
      The original document language.
      Returns:
      document language
    • getClientId

      public String getClientId()
      Microsoft API client id.
      Returns:
      client id
    • getClientSecret

      public String getClientSecret()
      Microsoft API client secret.
      Returns:
      client secret
    • getApiKey

      public String getApiKey()
      Google or Yandex API key.
      Returns:
      API key
    • getUserKey

      public String getUserKey()
      Lingo24 user key.
      Returns:
      user key
    • getSmtPath

      public String getSmtPath()
      Moses "smtPath".
      Returns:
      Moses "smtPath"
    • getScriptPath

      public String getScriptPath()
      Moses script path.
      Returns:
      script path
    • setApi

      public TranslatorSplitterConfig setApi(String api)
      Supported translation service API name. One of: "microsoft", "google", "lingo24", "moses", "yandex".
      Parameters:
      api - translation api name
      Returns:
      this.
    • setIgnoreNonTranslatedFields

      public TranslatorSplitterConfig setIgnoreNonTranslatedFields(boolean ignoreNonTranslatedFields)
      Whether to ignore fields not translated when creating child documents. Set to true if you just want children documents to contain fields for which there was a translation (and possibly, the translated content).
      Parameters:
      ignoreNonTranslatedFields - true to ignore non translated fields
      Returns:
      this.
    • setSourceLanguageField

      public TranslatorSplitterConfig setSourceLanguageField(String sourceLanguageField)
      The name of a field containing a value representing the original document language.
      Parameters:
      sourceLanguageField - field holding the document language
      Returns:
      this.
    • setSourceLanguage

      public TranslatorSplitterConfig setSourceLanguage(String sourceLanguage)
      The original document language.
      Parameters:
      sourceLanguage - document language
      Returns:
      this.
    • setClientId

      public TranslatorSplitterConfig setClientId(String clientId)
      Microsoft API client id.
      Parameters:
      clientId - client id
      Returns:
      this.
    • setClientSecret

      public TranslatorSplitterConfig setClientSecret(String clientSecret)
      Microsoft API client secret.
      Parameters:
      clientSecret - client secret
      Returns:
      this.
    • setApiKey

      public TranslatorSplitterConfig setApiKey(String apiKey)
      Google or Yandex API key.
      Parameters:
      apiKey - API key
      Returns:
      this.
    • setUserKey

      public TranslatorSplitterConfig setUserKey(String userKey)
      Lingo24 user key.
      Parameters:
      userKey - user key
      Returns:
      this.
    • setSmtPath

      public TranslatorSplitterConfig setSmtPath(String smtPath)
      Moses "smtPath".
      Parameters:
      smtPath - Moses "smtPath"
      Returns:
      this.
    • setScriptPath

      public TranslatorSplitterConfig setScriptPath(String scriptPath)
      Moses script path.
      Parameters:
      scriptPath - script path
      Returns:
      this.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class BaseDocumentSplitterConfig
    • canEqual

      protected boolean canEqual(Object other)
      Overrides:
      canEqual in class BaseDocumentSplitterConfig
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class BaseDocumentSplitterConfig
    • toString

      public String toString()
      Overrides:
      toString in class BaseDocumentSplitterConfig