/** * Identifies concepts in a piece of text. * * @param parameters The parameters to be used in the service call, account_id, graph and text are * required. * <ul> * <li>String account_id - The account identifier.<br> * <li>String graph - The graph name.<br> * <li>String text - The text to annotate.<br> * </ul> * * @return {@link Annotations} */ public Annotations annotateText(Map<String, Object> parameters) { Validate.notNull(parameters.get(ACCOUNT_ID), "account_id can't be null"); Validate.notNull(parameters.get(GRAPH), "graph can't be null"); Validate.notNull(parameters.get(TEXT), "text can't be null"); String graphId = createGraphIdPath((String) parameters.get(ACCOUNT_ID), (String) parameters.get(GRAPH)); HttpRequestBase request = Request.Post(graphId + ANNOTATE_TEXT_PATH) .withContent((String) parameters.get(TEXT), MediaType.TEXT_PLAIN) .withHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) .build(); try { HttpResponse response = execute(request); Annotations annotations = GsonSingleton.getGson().fromJson(ResponseUtil.getString(response), Annotations.class); return annotations; } catch (IOException e) { throw new RuntimeException(e); } }