Class Microsoft
- java.lang.Object
-
- com.api.sentimentanalysis.externalapi.translator.Microsoft
-
- All Implemented Interfaces:
TranslatorAPI
public class Microsoft extends java.lang.Object implements TranslatorAPI
This class contains a method to translate a text with Microsoft API.- Author:
- Ariadna de Arriba
-
-
Constructor Summary
Constructors Constructor Description Microsoft(java.lang.String apiKey)Constructor.
-
Method Summary
Modifier and Type Method Description java.lang.Stringtranslate(java.lang.String text, java.lang.String lang_src, java.lang.String lang_dest)Make a request to Microsoft translator API to translate a text.
-
-
-
Method Detail
-
translate
public java.lang.String translate(java.lang.String text, java.lang.String lang_src, java.lang.String lang_dest) throws java.io.IOException, org.json.simple.parser.ParseExceptionMake a request to Microsoft translator API to translate a text.- Specified by:
translatein interfaceTranslatorAPI- Parameters:
text- Text to translate.lang_src- Language of the original text. For example: 'en'lang_dest- Language to translate the text. For example: 'es'- Returns:
- Returns a string which represents a json with the translated text.
- Throws:
org.json.simple.parser.ParseException-caused parsing the json.java.io.IOException-caused by an error in the API call.
-
-