Search in sources :

Example 1 with AnnotatedText

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);
}
Also used : AnnotatedText(com.graphaware.nlp.domain.AnnotatedText)

Example 2 with AnnotatedText

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);
}
Also used : TextProcessor(com.graphaware.nlp.processor.TextProcessor) AnnotatedText(com.graphaware.nlp.domain.AnnotatedText)

Example 3 with AnnotatedText

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()));
}
Also used : TextProcessor(com.graphaware.nlp.processor.TextProcessor) AnnotatedText(com.graphaware.nlp.domain.AnnotatedText)

Example 4 with AnnotatedText

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);
}
Also used : TextProcessor(com.graphaware.nlp.processor.TextProcessor) AnnotatedText(com.graphaware.nlp.domain.AnnotatedText)

Example 5 with AnnotatedText

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;
    }
}
Also used : AnnotatedText(com.graphaware.nlp.domain.AnnotatedText) WorkflowInputEndOfQueueEntry(com.graphaware.nlp.workflow.input.WorkflowInputEndOfQueueEntry)

Aggregations

AnnotatedText (com.graphaware.nlp.domain.AnnotatedText)32 Test (org.junit.Test)18 Sentence (com.graphaware.nlp.domain.Sentence)17 Tag (com.graphaware.nlp.domain.Tag)11 TextProcessor (com.graphaware.nlp.processor.TextProcessor)9 TestAnnotatedText (com.graphaware.nlp.util.TestAnnotatedText)8 NLPIntegrationTest (com.graphaware.nlp.NLPIntegrationTest)5 TagUtils.newTag (com.graphaware.nlp.util.TagUtils.newTag)5 TestNLPGraph (com.graphaware.nlp.util.TestNLPGraph)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 Transaction (org.neo4j.graphdb.Transaction)5 StanfordTextProcessor (com.graphaware.nlp.processor.stanford.StanfordTextProcessor)3 StubTextProcessor (com.graphaware.nlp.stub.StubTextProcessor)3 StanfordCoreNLP (edu.stanford.nlp.pipeline.StanfordCoreNLP)3 Arrays (java.util.Arrays)3 Collections (java.util.Collections)3 Assert (org.junit.Assert)3 Before (org.junit.Before)3 Node (org.neo4j.graphdb.Node)3 PipelineSpecification (com.graphaware.nlp.dsl.request.PipelineSpecification)2