use of net.codestory.http.annotations.Post in project datashare by ICIJ.
the class NerResource method getAnnotations.
/**
* When datashare is launched in NER mode (without index) it exposes a name finding HTTP API. The text is sent with the HTTP body.
*
* @param pipeline to use
* @param text to analyse in the request body
* @return list of NamedEntities annotations
*
* Example :
* $(curl -XPOST http://dsenv:8080/api/ner/findNames/CORENLP -d "Please find attached a PDF copy of the advance tax clearance obtained for our client John Doe.")
*/
@Post("/findNames/:pipeline")
public List<NamedEntity> getAnnotations(final String pipeline, String text) throws Exception {
LoggerFactory.getLogger(getClass()).info(String.valueOf(getClass().getClassLoader()));
Pipeline p = pipelineRegistry.get(Pipeline.Type.parse(pipeline));
Language language = languageGuesser.guess(text);
if (p.initialize(language)) {
return p.process(DocumentBuilder.createDoc("inline").with(text).with(language).build());
}
return emptyList();
}