Search in sources :

Example 6 with DynamicConfiguration

use of com.graphaware.nlp.configuration.DynamicConfiguration in project neo4j-nlp by graphaware.

the class MicrosoftEnricherTest method testCanGetConceptsFromMicrosoft.

@Test
public void testCanGetConceptsFromMicrosoft() {
    PersistenceRegistry registry = new PersistenceRegistry(getDatabase());
    MicrosoftConceptEnricher enricher = new MicrosoftConceptEnricher(getDatabase(), registry, new TextProcessorsManager(new DynamicConfiguration(getDatabase())));
    clearDb();
    executeInTransaction("CALL ga.nlp.annotate({text: 'kill cats', id: 'test-proc', pipeline: 'tokenizer'})", emptyConsumer());
    try (Transaction tx = getDatabase().beginTx()) {
        getDatabase().findNodes(Label.label("AnnotatedText")).stream().forEach(node -> {
            ConceptRequest request = new ConceptRequest();
            request.setAnnotatedNode(node);
            // request.setLanguage("en");
            request.setDepth(1);
            request.setProcessor(StubTextProcessor.class.getName());
            enricher.importConcept(request);
            tx.success();
        });
    }
    debugTagsRelations();
    TestNLPGraph tester = new TestNLPGraph(getDatabase());
    tester.assertTagWithValueExist("pet");
    tester.assertTagWithValueExist("specie");
    tester.assertTagHasRelatedTag("cats", "animal");
    tester.assertTagHasRelatedTag("cats", "pet");
}
Also used : PersistenceRegistry(com.graphaware.nlp.persistence.PersistenceRegistry) DynamicConfiguration(com.graphaware.nlp.configuration.DynamicConfiguration) Transaction(org.neo4j.graphdb.Transaction) TextProcessorsManager(com.graphaware.nlp.processor.TextProcessorsManager) TestNLPGraph(com.graphaware.nlp.util.TestNLPGraph) ConceptRequest(com.graphaware.nlp.dsl.request.ConceptRequest) StubTextProcessor(com.graphaware.nlp.stub.StubTextProcessor) EnricherAbstractTest(com.graphaware.nlp.enrich.EnricherAbstractTest) Test(org.junit.Test)

Example 7 with DynamicConfiguration

use of com.graphaware.nlp.configuration.DynamicConfiguration in project neo4j-nlp by graphaware.

the class MicrosoftEnricherTest method testEnricherNameIsSetAsRelationshipProperty.

@Test
public void testEnricherNameIsSetAsRelationshipProperty() {
    DynamicConfiguration configuration = new DynamicConfiguration(getDatabase());
    PersistenceRegistry registry = new PersistenceRegistry(getDatabase());
    MicrosoftConceptEnricher enricher = new MicrosoftConceptEnricher(getDatabase(), registry, new TextProcessorsManager(new DynamicConfiguration(getDatabase())));
    clearDb();
    executeInTransaction("CALL ga.nlp.annotate({text: 'kill cats', id: 'test-proc', pipeline: 'tokenizer'})", emptyConsumer());
    try (Transaction tx = getDatabase().beginTx()) {
        getDatabase().findNodes(Label.label("AnnotatedText")).stream().forEach(node -> {
            ConceptRequest request = new ConceptRequest();
            request.setAnnotatedNode(node);
            // request.setLanguage("en");
            request.setDepth(1);
            request.setProcessor(StubTextProcessor.class.getName());
            enricher.importConcept(request);
            tx.success();
        });
    }
    try (Transaction tx = getDatabase().beginTx()) {
        getDatabase().getAllRelationships().stream().forEach(r -> {
            if (r.isType(RelationshipType.withName("IS_RELATED_TO"))) {
                assertTrue(r.hasProperty("source"));
                assertEquals(MicrosoftConceptEnricher.ENRICHER_NAME, r.getProperty("source").toString());
            }
        });
        tx.success();
    }
}
Also used : PersistenceRegistry(com.graphaware.nlp.persistence.PersistenceRegistry) DynamicConfiguration(com.graphaware.nlp.configuration.DynamicConfiguration) Transaction(org.neo4j.graphdb.Transaction) TextProcessorsManager(com.graphaware.nlp.processor.TextProcessorsManager) ConceptRequest(com.graphaware.nlp.dsl.request.ConceptRequest) StubTextProcessor(com.graphaware.nlp.stub.StubTextProcessor) EnricherAbstractTest(com.graphaware.nlp.enrich.EnricherAbstractTest) Test(org.junit.Test)

Example 8 with DynamicConfiguration

use of com.graphaware.nlp.configuration.DynamicConfiguration in project neo4j-nlp by graphaware.

the class AnnotationPersistenceIntegrationTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    clearDatabase();
    manager = NLPManager.getInstance();
    manager.init(getDatabase(), new DynamicConfiguration(getDatabase()));
    createPipeline(pipelineSpecification.getTextProcessor(), pipelineSpecification.getName());
}
Also used : DynamicConfiguration(com.graphaware.nlp.configuration.DynamicConfiguration) Before(org.junit.Before)

Example 9 with DynamicConfiguration

use of com.graphaware.nlp.configuration.DynamicConfiguration in project neo4j-nlp by graphaware.

the class TextRankTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    manager = NLPManager.getInstance();
    manager.init(getDatabase(), new DynamicConfiguration(getDatabase()));
    createPipeline(pipelineSpecification.getTextProcessor(), pipelineSpecification.getName());
}
Also used : DynamicConfiguration(com.graphaware.nlp.configuration.DynamicConfiguration) Before(org.junit.Before)

Example 10 with DynamicConfiguration

use of com.graphaware.nlp.configuration.DynamicConfiguration in project neo4j-nlp by graphaware.

the class ConceptNet5EnricherIntegrationTest method testConceptNetUrlIsConfigurable.

@Test
public void testConceptNetUrlIsConfigurable() {
    PersistenceRegistry registry = new PersistenceRegistry(getDatabase());
    ConceptNet5Enricher enricher = new ConceptNet5Enricher(getDatabase(), registry, new TextProcessorsManager(new DynamicConfiguration(getDatabase())));
    assertEquals("http://api.conceptnet.io", enricher.getConceptNetUrl());
    getNLPManager().getConfiguration().updateInternalSetting("CONCEPT_NET_5_URL", "http://localhost:8001");
    assertEquals("http://localhost:8001", enricher.getConceptNetUrl());
}
Also used : PersistenceRegistry(com.graphaware.nlp.persistence.PersistenceRegistry) DynamicConfiguration(com.graphaware.nlp.configuration.DynamicConfiguration) TextProcessorsManager(com.graphaware.nlp.processor.TextProcessorsManager) EnricherAbstractTest(com.graphaware.nlp.enrich.EnricherAbstractTest) Test(org.junit.Test)

Aggregations

DynamicConfiguration (com.graphaware.nlp.configuration.DynamicConfiguration)10 EnricherAbstractTest (com.graphaware.nlp.enrich.EnricherAbstractTest)7 PersistenceRegistry (com.graphaware.nlp.persistence.PersistenceRegistry)7 TextProcessorsManager (com.graphaware.nlp.processor.TextProcessorsManager)7 Test (org.junit.Test)7 ConceptRequest (com.graphaware.nlp.dsl.request.ConceptRequest)6 StubTextProcessor (com.graphaware.nlp.stub.StubTextProcessor)6 Transaction (org.neo4j.graphdb.Transaction)6 TestNLPGraph (com.graphaware.nlp.util.TestNLPGraph)5 Before (org.junit.Before)5 TextProcessor (com.graphaware.nlp.processor.TextProcessor)3 Arrays (java.util.Arrays)3 Collections (java.util.Collections)3 Assert (org.junit.Assert)3 Ignore (org.junit.Ignore)3 Label (org.neo4j.graphdb.Label)3