Search in sources :

Example 1 with InvalidTextProcessorException

use of com.graphaware.nlp.exception.InvalidTextProcessorException in project neo4j-nlp by graphaware.

the class TextProcessorsManager method retrieveTextProcessor.

public TextProcessor retrieveTextProcessor(String processor, String pipeline) {
    TextProcessor newTP;
    if (processor != null && processor.length() > 0) {
        newTP = getTextProcessor(processor);
        if (newTP == null) {
            throw new InvalidTextProcessorException("Text processor " + processor + " doesn't exist");
        }
    } else {
        newTP = getDefaultProcessor();
    }
    if (pipeline != null && pipeline.length() > 0) {
        if (!newTP.checkPipeline(pipeline)) {
            throw new RuntimeException("Pipeline with name " + pipeline + " doesn't exist for processor " + newTP.getClass().getName());
        }
    } else {
        throw new InvalidPipelineException("Pipeline not specified");
    }
    LOG.info("Using text processor: " + newTP.getClass().getName());
    return newTP;
}
Also used : NLPTextProcessor(com.graphaware.nlp.annotation.NLPTextProcessor) InvalidTextProcessorException(com.graphaware.nlp.exception.InvalidTextProcessorException) InvalidPipelineException(com.graphaware.nlp.exception.InvalidPipelineException)

Aggregations

NLPTextProcessor (com.graphaware.nlp.annotation.NLPTextProcessor)1 InvalidPipelineException (com.graphaware.nlp.exception.InvalidPipelineException)1 InvalidTextProcessorException (com.graphaware.nlp.exception.InvalidTextProcessorException)1