Search in sources :

Example 41 with PipelineSpecification

use of com.graphaware.nlp.dsl.request.PipelineSpecification in project neo4j-nlp by graphaware.

the class NLPExtensionIntegrationTest method testExtensionsCanPersistData.

@Test
public void testExtensionsCanPersistData() {
    try (Transaction tx = getDatabase().beginTx()) {
        getNLPManager().annotateTextAndPersist("Hello world", "id-123", pipelineSpecification);
        tx.success();
    }
    executeInTransaction("MATCH (n:AnnotatedText) RETURN n", (result -> {
        assertTrue(result.hasNext());
        Node at = (Node) result.next().get("n");
        assertTrue(at.hasLabel(Label.label("STUB_Event")));
    }));
}
Also used : Label(org.neo4j.graphdb.Label) StubExtension(com.graphaware.nlp.stub.StubExtension) TextProcessor(com.graphaware.nlp.processor.TextProcessor) Test(org.junit.Test) PipelineSpecification(com.graphaware.nlp.dsl.request.PipelineSpecification) Transaction(org.neo4j.graphdb.Transaction) Assert(org.junit.Assert) NLPIntegrationTest(com.graphaware.nlp.NLPIntegrationTest) StubTextProcessor(com.graphaware.nlp.stub.StubTextProcessor) Node(org.neo4j.graphdb.Node) Before(org.junit.Before) Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) Test(org.junit.Test) NLPIntegrationTest(com.graphaware.nlp.NLPIntegrationTest)

Example 42 with PipelineSpecification

use of com.graphaware.nlp.dsl.request.PipelineSpecification in project neo4j-nlp by graphaware.

the class TextProcessorsManager method annotateTags.

public List<Tag> annotateTags(String text, String language) {
    PipelineSpecification spec = getDefaultPipeline(language);
    TextProcessor processor = getTextProcessor(spec.getTextProcessor());
    return processor.annotateTags(text, spec);
}
Also used : PipelineSpecification(com.graphaware.nlp.dsl.request.PipelineSpecification) NLPTextProcessor(com.graphaware.nlp.annotation.NLPTextProcessor)

Example 43 with PipelineSpecification

use of com.graphaware.nlp.dsl.request.PipelineSpecification in project neo4j-nlp by graphaware.

the class TextProcessorsManager method setDefaultPipeline.

public void setDefaultPipeline(String pipelineName, String language) {
    PipelineSpecification pipelineSpecification = configuration.loadPipeline(pipelineName);
    if (null == pipelineSpecification) {
        throw new RuntimeException("No pipeline " + pipelineName + " exist");
    }
    setDefaultPipelineAux(language, pipelineSpecification);
}
Also used : PipelineSpecification(com.graphaware.nlp.dsl.request.PipelineSpecification)

Example 44 with PipelineSpecification

use of com.graphaware.nlp.dsl.request.PipelineSpecification in project neo4j-nlp by graphaware.

the class TextProcessorsManager method getDefaultPipelineSpecificationFromConfig.

private PipelineSpecification getDefaultPipelineSpecificationFromConfig(String language) {
    String pipelineName = (String) configuration.getSettingValueFor(getDefaultPipelineKey(language));
    if (pipelineName == null) {
        LOG.warn("Something goes wrong (this shouldn't happen) default pipeline not available, key: " + getDefaultPipelineKey(language));
        return null;
    }
    PipelineSpecification pipelineSpecification = configuration.loadPipeline(pipelineName);
    if (pipelineSpecification == null) {
        LOG.warn("Default pipeline specification for " + pipelineName + " not available");
        return null;
    }
    return pipelineSpecification;
}
Also used : PipelineSpecification(com.graphaware.nlp.dsl.request.PipelineSpecification)

Example 45 with PipelineSpecification

use of com.graphaware.nlp.dsl.request.PipelineSpecification in project neo4j-nlp by graphaware.

the class WorkflowTextProcessor method init.

@Override
public void init(Map<String, Object> parameters) {
    setConfiguration(new WorkflowTextProcessorConfiguration(parameters));
    PipelineSpecification pipelineSpecification = NLPManager.getInstance().getTextProcessorsManager().getPipelineSpecification(getConfiguration().getPipeline());
    if (null != pipelineSpecification) {
        textProcessor = NLPManager.getInstance().getTextProcessorsManager().getTextProcessor(pipelineSpecification.getTextProcessor());
        setValid(true);
    } else {
        LOG.error("Error while initializing the processor. Setting to invalid");
        setValid(false);
    }
}
Also used : PipelineSpecification(com.graphaware.nlp.dsl.request.PipelineSpecification)

Aggregations

PipelineSpecification (com.graphaware.nlp.dsl.request.PipelineSpecification)49 Test (org.junit.Test)22 StubTextProcessor (com.graphaware.nlp.stub.StubTextProcessor)13 StanfordTextProcessor (com.graphaware.nlp.processor.stanford.StanfordTextProcessor)11 NLPIntegrationTest (com.graphaware.nlp.NLPIntegrationTest)8 TestAnnotatedText (com.graphaware.nlp.util.TestAnnotatedText)8 Transaction (org.neo4j.graphdb.Transaction)8 AbstractEmbeddedTest (com.graphaware.nlp.AbstractEmbeddedTest)5 NLPTextProcessor (com.graphaware.nlp.annotation.NLPTextProcessor)4 TextProcessor (com.graphaware.nlp.processor.TextProcessor)3 CoreAnnotations (edu.stanford.nlp.ling.CoreAnnotations)3 Annotation (edu.stanford.nlp.pipeline.Annotation)3 StanfordCoreNLP (edu.stanford.nlp.pipeline.StanfordCoreNLP)3 SemanticGraph (edu.stanford.nlp.semgraph.SemanticGraph)3 SemanticGraphCoreAnnotations (edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations)3 SemanticGraphEdge (edu.stanford.nlp.semgraph.SemanticGraphEdge)3 CoreMap (edu.stanford.nlp.util.CoreMap)3 Description (org.neo4j.procedure.Description)3 LoggerFactory (com.graphaware.common.log.LoggerFactory)2 NLPManager (com.graphaware.nlp.NLPManager)2