Search in sources :

Example 1 with InvalidTextException

use of com.graphaware.nlp.exception.InvalidTextException 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;
}
Also used : NLPTextProcessor(com.graphaware.nlp.annotation.NLPTextProcessor) AnnotatedText(com.graphaware.nlp.domain.AnnotatedText) InvalidTextException(com.graphaware.nlp.exception.InvalidTextException) TextAnalysisException(com.graphaware.nlp.exception.TextAnalysisException) InvalidPipelineException(com.graphaware.nlp.exception.InvalidPipelineException) InvalidTextProcessorException(com.graphaware.nlp.exception.InvalidTextProcessorException) InvalidTextException(com.graphaware.nlp.exception.InvalidTextException) TextAnalysisException(com.graphaware.nlp.exception.TextAnalysisException)

Aggregations

NLPTextProcessor (com.graphaware.nlp.annotation.NLPTextProcessor)1 AnnotatedText (com.graphaware.nlp.domain.AnnotatedText)1 InvalidPipelineException (com.graphaware.nlp.exception.InvalidPipelineException)1 InvalidTextException (com.graphaware.nlp.exception.InvalidTextException)1 InvalidTextProcessorException (com.graphaware.nlp.exception.InvalidTextProcessorException)1 TextAnalysisException (com.graphaware.nlp.exception.TextAnalysisException)1