use of com.graphaware.nlp.exception.TextAnalysisException in project neo4j-nlp by graphaware.
the class TextProcessorsManager method annotate.
public AnnotatedText annotate(String text, PipelineSpecification pipelineSpecification) {
if (null == pipelineSpecification) {
throw new RuntimeException("No pipeline " + pipelineSpecification.name + " found.");
}
if (text.trim().equalsIgnoreCase("")) {
throw new InvalidTextException();
}
TextProcessor processor = getTextProcessor(pipelineSpecification.getTextProcessor());
long startTime = -System.currentTimeMillis();
AnnotatedText annotatedText;
try {
annotatedText = processor.annotateText(text, pipelineSpecification);
} catch (Exception e) {
throw new TextAnalysisException(e.getMessage(), e);
}
LOG.info("Time to annotate " + (System.currentTimeMillis() + startTime));
return annotatedText;
}
Aggregations