use of com.graphaware.nlp.domain.AnnotatedText in project neo4j-nlp by graphaware.
the class NLPManager method annotateTextAndPersist.
public Node annotateTextAndPersist(String text, String id, String pipelineName) {
PipelineSpecification pipelineSpecification = textProcessorsManager.getPipelineSpecification(pipelineName);
LOG.info("Annotating with ID " + id);
AnnotatedText at = textProcessorsManager.annotate(text, pipelineSpecification);
return processAnnotationPersist(id, text, at, pipelineSpecification);
}
use of com.graphaware.nlp.domain.AnnotatedText in project neo4j-nlp by graphaware.
the class NLPManager method filter.
public Boolean filter(FilterRequest filterRequest) {
String text = filterRequest.getText();
String filter = filterRequest.getFilter();
PipelineSpecification pipelineSpecification = textProcessorsManager.getPipelineSpecification(filterRequest.getPipeline());
TextProcessor currentTP = textProcessorsManager.getTextProcessor(pipelineSpecification.getTextProcessor());
AnnotatedText annotatedText = currentTP.annotateText(text, pipelineSpecification);
return annotatedText.filter(filter);
}
use of com.graphaware.nlp.domain.AnnotatedText in project neo4j-nlp by graphaware.
the class NLPManager method applySentiment.
public void applySentiment(Node node, String textProcessor) {
TextProcessor processor = textProcessor.equals("") ? getTextProcessorsManager().getDefaultProcessor() : getTextProcessorsManager().getTextProcessor(textProcessor);
AnnotatedText annotatedText = (AnnotatedText) getPersister(AnnotatedText.class).fromNode(node);
processor.sentiment(annotatedText);
getPersister(AnnotatedText.class).persist(annotatedText, node.getProperty(configuration.getPropertyKeyFor(Properties.PROPERTY_ID)).toString(), String.valueOf(System.currentTimeMillis()));
}
use of com.graphaware.nlp.domain.AnnotatedText in project neo4j-nlp by graphaware.
the class NLPManager method annotateTextAndPersist.
public Node annotateTextAndPersist(String text, String id, PipelineSpecification pipelineSpecification) {
TextProcessor processor = textProcessorsManager.getTextProcessor(pipelineSpecification.getTextProcessor());
LOG.info("Annotating with ID " + id);
AnnotatedText annotatedText = processor.annotateText(text, pipelineSpecification);
return processAnnotationPersist(id, text, annotatedText, pipelineSpecification);
}
use of com.graphaware.nlp.domain.AnnotatedText in project neo4j-nlp by graphaware.
the class WorkflowTextProcessor method handle.
@Override
public void handle(WorkflowInputEntry entry) {
if (entry instanceof WorkflowInputEndOfQueueEntry) {
super.checkAndHandle(new WorkflowProcessorEndOfQueueEntry());
return;
}
if (isValid()) {
AnnotatedText annotateText = NLPManager.getInstance().getTextProcessorsManager().annotate(entry.getText(), getConfiguration().getPipeline());
super.checkAndHandle(new WorkflowProcessorOutputEntry(annotateText, entry.getId()));
} else {
LOG.warn("The Processor " + this.getName() + " is in an invalid state");
return;
}
}
Aggregations