/** * Updates existing corpus meta-data (access and permissions). * * @param accountId String the Account identifier. * @param corpus {@link Corpus} the corpus to update. */ public void updateCorpus(final String accountId, final Corpus corpus) { Validate.notNull(accountId, "account_id can't be null"); Validate.notNull(corpus, "corpus can't be null"); Validate.notNull(corpus.getId(), "corpus.id can't be null"); HttpRequestBase request = Request.Post(createCorpusIdPath(accountId, corpus.getId())) .withContent(GsonSingleton.getGson().toJson(corpus), MediaType.APPLICATION_JSON) .build(); executeWithoutResponse(request); }
/** * Updates a document in a given corpus. * * @param accountId String the account identifier, * @param corpusName String the corpus name. * @param document {@link Document} The document to update. */ public void updateDocument( final String accountId, final String corpusName, final Document document) { Validate.notNull(accountId, "accountId can't be null"); Validate.notNull(corpusName, "corpusName can't be null"); Validate.notNull(document, "document can't be null"); Validate.notNull(document.getId(), "document.id can't be null"); HttpRequestBase request = Request.Post(createDocumentIdPath(accountId, corpusName, document.getId())) .withContent(GsonSingleton.getGson().toJson(document), MediaType.APPLICATION_JSON) .build(); executeWithoutResponse(request); }
/** * 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); } }