Class TranslatorSplitterConfig
java.lang.Object
com.norconex.importer.handler.BaseLabelableConfig
com.norconex.importer.handler.BaseDocHandlerConfig
com.norconex.importer.handler.splitter.BaseDocumentSplitterConfig
com.norconex.importer.handler.splitter.impl.TranslatorSplitterConfig
- All Implemented Interfaces:
Labelable
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:
- microsoft
- clientId
- clientSecret
- google
- apiKey
- lingo24
- userKey
- moses
- smtPath
- scriptPath
- yandex
- apiKey
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleangetApi()Supported translation service API name.Google or Yandex API key.Microsoft API client id.Microsoft API client secret.Optional matcher of fields holding content to translate instead of document body.Moses script path.Moses "smtPath".The original document language.The name of a field containing a value representing the original document language.Lingo24 user key.inthashCode()booleanWhether to ignore fields not translated when creating child documents.Supported translation service API name.Google or Yandex API key.setClientId(String clientId) Microsoft API client id.setClientSecret(String clientSecret) Microsoft API client secret.setFieldMatcher(TextMatcher fieldMatcher) setIgnoreNonTranslatedFields(boolean ignoreNonTranslatedFields) Whether to ignore fields not translated when creating child documents.setScriptPath(String scriptPath) Moses script path.setSmtPath(String smtPath) Moses "smtPath".setSourceLanguage(String sourceLanguage) The original document language.setSourceLanguageField(String sourceLanguageField) The name of a field containing a value representing the original document language.setTargetLanguages(List<String> targetLanguages) setUserKey(String userKey) Lingo24 user key.toString()Methods inherited from class com.norconex.importer.handler.splitter.BaseDocumentSplitterConfig
isDiscardOriginal, setDiscardOriginalMethods inherited from class com.norconex.importer.handler.BaseLabelableConfig
getLabel, setLabel
-
Field Details
-
API_MICROSOFT
- See Also:
-
API_GOOGLE
- See Also:
-
API_LINGO24
- See Also:
-
API_MOSES
- See Also:
-
API_YANDEX
- See Also:
-
-
Constructor Details
-
TranslatorSplitterConfig
public TranslatorSplitterConfig()
-
-
Method Details
-
setFieldMatcher
-
getTargetLanguages
-
setTargetLanguages
-
getApi
Supported translation service API name. One of: "microsoft", "google", "lingo24", "moses", "yandex".- Returns:
- translation api name
-
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 totrueif 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
The name of a field containing a value representing the original document language.- Returns:
- field holding the document language
-
getSourceLanguage
The original document language.- Returns:
- document language
-
getClientId
Microsoft API client id.- Returns:
- client id
-
getClientSecret
Microsoft API client secret.- Returns:
- client secret
-
getApiKey
Google or Yandex API key.- Returns:
- API key
-
getUserKey
Lingo24 user key.- Returns:
- user key
-
getSmtPath
Moses "smtPath".- Returns:
- Moses "smtPath"
-
getScriptPath
Moses script path.- Returns:
- script path
-
setApi
Supported translation service API name. One of: "microsoft", "google", "lingo24", "moses", "yandex".- Parameters:
api- translation api name- Returns:
this.
-
setIgnoreNonTranslatedFields
Whether to ignore fields not translated when creating child documents. Set totrueif you just want children documents to contain fields for which there was a translation (and possibly, the translated content).- Parameters:
ignoreNonTranslatedFields-trueto ignore non translated fields- Returns:
this.
-
setSourceLanguageField
The name of a field containing a value representing the original document language.- Parameters:
sourceLanguageField- field holding the document language- Returns:
this.
-
setSourceLanguage
The original document language.- Parameters:
sourceLanguage- document language- Returns:
this.
-
setClientId
Microsoft API client id.- Parameters:
clientId- client id- Returns:
this.
-
setClientSecret
Microsoft API client secret.- Parameters:
clientSecret- client secret- Returns:
this.
-
setApiKey
Google or Yandex API key.- Parameters:
apiKey- API key- Returns:
this.
-
setUserKey
Lingo24 user key.- Parameters:
userKey- user key- Returns:
this.
-
setSmtPath
Moses "smtPath".- Parameters:
smtPath- Moses "smtPath"- Returns:
this.
-
setScriptPath
Moses script path.- Parameters:
scriptPath- script path- Returns:
this.
-
equals
- Overrides:
equalsin classBaseDocumentSplitterConfig
-
canEqual
- Overrides:
canEqualin classBaseDocumentSplitterConfig
-
hashCode
public int hashCode()- Overrides:
hashCodein classBaseDocumentSplitterConfig
-
toString
- Overrides:
toStringin classBaseDocumentSplitterConfig
-