'Translates text from a source language to a target language'

def translate(self, text, source=None, target=None, model_id=None):

    if ((model_id is None) and ((source is None) or (target is None))):
        raise WatsonInvalidArgument('Either    model_id    or    source    and    target    must    be    specified')
    data = {'text': text, 'source': source, 'target': target, 'model_id': model_id}
    return self.request(method='POST', url='/v2/translate', json=data).text
