Class GoogleMTv3APIImpl
- java.lang.Object
-
- net.sf.okapi.connectors.google.v3.GoogleMTv3APIImpl
-
- All Implemented Interfaces:
AutoCloseable,GoogleMTv3API
public class GoogleMTv3APIImpl extends Object implements GoogleMTv3API
Implementation of Google Cloud Translation API v3 using the official Google Cloud Java Client.
-
-
Constructor Summary
Constructors Constructor Description GoogleMTv3APIImpl(GoogleMTv3Parameters params)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the underlying client resources.List<String>getLanguages()Get the list of supported language codes.<T> List<TranslationResponse>translate(GoogleQueryBuilder<T> qb)Translate a batch of text segments.<T> TranslationResponsetranslateSingleSegment(GoogleQueryBuilder<T> qb, String sourceText)Translate a single text segment.
-
-
-
Constructor Detail
-
GoogleMTv3APIImpl
public GoogleMTv3APIImpl(GoogleMTv3Parameters params)
-
-
Method Detail
-
translate
public <T> List<TranslationResponse> translate(GoogleQueryBuilder<T> qb) throws GoogleMTv3ErrorException
Description copied from interface:GoogleMTv3APITranslate a batch of text segments. * @param qb the query builder containing the segments to translate- Specified by:
translatein interfaceGoogleMTv3API- Returns:
- list of translation responses
- Throws:
GoogleMTv3ErrorException- if an error occurs during translation
-
translateSingleSegment
public <T> TranslationResponse translateSingleSegment(GoogleQueryBuilder<T> qb, String sourceText) throws GoogleMTv3ErrorException
Description copied from interface:GoogleMTv3APITranslate a single text segment. * @param qb the query builder for context- Specified by:
translateSingleSegmentin interfaceGoogleMTv3APIsourceText- the text to translate- Returns:
- translation response
- Throws:
GoogleMTv3ErrorException- if an error occurs during translation
-
getLanguages
public List<String> getLanguages() throws GoogleMTv3ErrorException
Description copied from interface:GoogleMTv3APIGet the list of supported language codes. * @return list of BCP-47 language codes- Specified by:
getLanguagesin interfaceGoogleMTv3API- Throws:
GoogleMTv3ErrorException- if an error occurs retrieving languages
-
close
public void close()
Description copied from interface:GoogleMTv3APICloses the underlying client resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceGoogleMTv3API
-
-