Class 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.String translate​(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.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Microsoft

        public Microsoft​(java.lang.String apiKey)
        Constructor.
        Parameters:
        apiKey - Api-key to authorize the method.
    • 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.ParseException
        Make a request to Microsoft translator API to translate a text.
        Specified by:
        translate in interface TranslatorAPI
        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.