Search in sources :

Example 1 with EventDispatcher

use of com.graphaware.nlp.event.EventDispatcher in project neo4j-nlp by graphaware.

the class NLPManager method init.

public void init(GraphDatabaseService database, DynamicConfiguration configuration) {
    if (initialized) {
        return;
    }
    this.configuration = configuration;
    this.languageManager = new LanguageManager();
    this.database = database;
    this.persistenceRegistry = new PersistenceRegistry(database);
    this.enrichmentRegistry = buildAndRegisterEnrichers();
    this.eventDispatcher = new EventDispatcher();
    loadExtensions();
    if (textProcessorsManager == null) {
        this.textProcessorsManager = new TextProcessorsManager(configuration);
    }
    this.textProcessorsManager.registerPipelinesFromConfig();
    loadVectorComputationProcesses();
    loadSummarizers();
    registerWord2VecModelFromConfig();
    initialized = true;
}
Also used : PersistenceRegistry(com.graphaware.nlp.persistence.PersistenceRegistry) EventDispatcher(com.graphaware.nlp.event.EventDispatcher) TextProcessorsManager(com.graphaware.nlp.processor.TextProcessorsManager) LanguageManager(com.graphaware.nlp.language.LanguageManager)

Example 2 with EventDispatcher

use of com.graphaware.nlp.event.EventDispatcher in project neo4j-nlp by graphaware.

the class NLPExtensionTest method testExtensionCanRegisterEventListeners.

@Test
public void testExtensionCanRegisterEventListeners() {
    Map<String, NLPExtension> loadedExtensions = ServiceLoader.loadInstances(NLPModuleExtension.class);
    EventDispatcher dispatcher = new EventDispatcher();
    loadedExtensions.values().forEach(nlpExtension -> {
        nlpExtension.registerEventListeners(dispatcher);
    });
    dispatcher.notify(StubEvents.HELLO, new DefaultEvent("hello you"));
    NLPExtension nlpExtension = loadedExtensions.get(StubExtension.class.getName());
    assertEquals("hello you", ((StubExtension) nlpExtension).getSomeValue());
}
Also used : DefaultEvent(com.graphaware.nlp.event.DefaultEvent) EventDispatcher(com.graphaware.nlp.event.EventDispatcher) StubExtension(com.graphaware.nlp.stub.StubExtension) Test(org.junit.Test)

Example 3 with EventDispatcher

use of com.graphaware.nlp.event.EventDispatcher in project neo4j-nlp by graphaware.

the class NLPManager method init.

public void init(GraphDatabaseService database, NLPConfiguration nlpConfiguration, DynamicConfiguration configuration) {
    if (initialized) {
        return;
    }
    this.nlpConfiguration = nlpConfiguration;
    this.textProcessorsManager = new TextProcessorsManager();
    this.configuration = configuration;
    this.database = database;
    this.persistenceRegistry = new PersistenceRegistry(database);
    this.enrichmentRegistry = buildAndRegisterEnrichers();
    this.eventDispatcher = new EventDispatcher();
    this.vectorComputation = new QueryBasedVectorComputation(database);
    loadExtensions();
    registerEventListeners();
    initialized = true;
    registerPipelinesFromConfig();
}
Also used : PersistenceRegistry(com.graphaware.nlp.persistence.PersistenceRegistry) EventDispatcher(com.graphaware.nlp.event.EventDispatcher) TextProcessorsManager(com.graphaware.nlp.processor.TextProcessorsManager) QueryBasedVectorComputation(com.graphaware.nlp.vector.QueryBasedVectorComputation)

Aggregations

EventDispatcher (com.graphaware.nlp.event.EventDispatcher)3 PersistenceRegistry (com.graphaware.nlp.persistence.PersistenceRegistry)2 TextProcessorsManager (com.graphaware.nlp.processor.TextProcessorsManager)2 DefaultEvent (com.graphaware.nlp.event.DefaultEvent)1 LanguageManager (com.graphaware.nlp.language.LanguageManager)1 StubExtension (com.graphaware.nlp.stub.StubExtension)1 QueryBasedVectorComputation (com.graphaware.nlp.vector.QueryBasedVectorComputation)1 Test (org.junit.Test)1