Search in sources :

Example 1 with Post

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();
}
Also used : Language(org.icij.datashare.text.Language) Pipeline(org.icij.datashare.text.nlp.Pipeline) Post(net.codestory.http.annotations.Post)

Aggregations

Post (net.codestory.http.annotations.Post)1 Language (org.icij.datashare.text.Language)1 Pipeline (org.icij.datashare.text.nlp.Pipeline)1