Search in sources :

Example 1 with StubTextProcessor

use of com.graphaware.nlp.stub.StubTextProcessor in project neo4j-nlp by graphaware.

the class AnnotationPersistenceIntegrationTest method testAnnotationRunWithPipelineDefaultFromUserConfig.

@Test
public void testAnnotationRunWithPipelineDefaultFromUserConfig() {
    manager.getConfiguration().updateInternalSetting(SettingsConstants.DEFAULT_PIPELINE, TextProcessor.DEFAULT_PIPELINE);
    try (Transaction tx = getDatabase().beginTx()) {
        manager.annotateTextAndPersist("hello my name is John. I am working for IBM. I live in Italy", "123", pipelineSpecification);
        tx.success();
    }
    try (Transaction tx = getDatabase().beginTx()) {
        getDatabase().findNodes(Label.label("AnnotatedText")).stream().forEach(node -> {
            manager.applySentiment(node, StubTextProcessor.class.getName());
        });
        tx.success();
    }
    TestNLPGraph tester = new TestNLPGraph(getDatabase());
    tester.assertSentenceWithIdHasSentimentLabel("123_0", SentimentLabels.VeryPositive.toString());
    assertEquals("tokenizer", ((StubTextProcessor) manager.getTextProcessorsManager().getTextProcessor("com.graphaware.nlp.stub.StubTextProcessor")).getLastPipelineUsed());
}
Also used : Transaction(org.neo4j.graphdb.Transaction) TestNLPGraph(com.graphaware.nlp.util.TestNLPGraph) StubTextProcessor(com.graphaware.nlp.stub.StubTextProcessor) Test(org.junit.Test) NLPIntegrationTest(com.graphaware.nlp.NLPIntegrationTest)

Aggregations

NLPIntegrationTest (com.graphaware.nlp.NLPIntegrationTest)1 StubTextProcessor (com.graphaware.nlp.stub.StubTextProcessor)1 TestNLPGraph (com.graphaware.nlp.util.TestNLPGraph)1 Test (org.junit.Test)1 Transaction (org.neo4j.graphdb.Transaction)1