use of com.graphaware.runtime.GraphAwareRuntime in project neo4j-nlp by graphaware.
the class ConfigurationMigrationTest method testPipelinesCanBeMigrated.
@Test
public void testPipelinesCanBeMigrated() throws Exception {
PipelineSpecification specification = new PipelineSpecification("custom", StubTextProcessor.class.getName());
specification.setStopWords("hello,hihi");
ObjectMapper mapper = new ObjectMapper();
String spec = mapper.writeValueAsString(specification);
try (Transaction tx = getDatabase().beginTx()) {
keyValueStore.set(DynamicConfiguration.STORE_KEY + "PIPELINE_" + specification.getName(), spec);
assertFalse(spec.contains("\"@class\""));
tx.success();
}
GraphAwareRuntime runtime = GraphAwareRuntimeFactory.createRuntime(getDatabase());
runtime.registerModule(new NLPModule("NLP", NLPConfiguration.defaultConfiguration(), getDatabase()));
runtime.start();
runtime.waitUntilStarted();
try (Transaction tx = getDatabase().beginTx()) {
String s = keyValueStore.get(DynamicConfiguration.STORE_KEY + "PIPELINE_" + specification.getName()).toString();
assertTrue(s.contains("\"@class\""));
tx.success();
}
}
use of com.graphaware.runtime.GraphAwareRuntime in project neo4j-nlp by graphaware.
the class DynamicConfigurationTest method testWorfklowItemsInfosShouldBeLoadedFromPreviousState.
@Test
public void testWorfklowItemsInfosShouldBeLoadedFromPreviousState() throws Exception {
resetSingleton();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
keyValueStore = new GraphKeyValueStore(getDatabase());
QueryBasedWorkflowInput workflowInput = new QueryBasedWorkflowInput("test", getDatabase());
DynamicConfiguration configuration = new DynamicConfiguration(getDatabase());
workflowInput.setConfiguration(new WorkflowInputQueryConfiguration(new HashMap<>()));
try (Transaction tx = getDatabase().beginTx()) {
configuration.storeWorkflowInstanceItem(workflowInput);
tx.success();
}
GraphAwareRuntime runtime = GraphAwareRuntimeFactory.createRuntime(getDatabase());
runtime.registerModule(new NLPModule("NLP", NLPConfiguration.defaultConfiguration(), getDatabase()));
runtime.start();
runtime.waitUntilStarted();
}
use of com.graphaware.runtime.GraphAwareRuntime in project neo4j-nlp by graphaware.
the class DynamicConfigurationTest method testConfigurationValuesShouldBeLoadedFromPreviousState.
@Test
public void testConfigurationValuesShouldBeLoadedFromPreviousState() throws Exception {
resetSingleton();
ObjectMapper mapper = new ObjectMapper();
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
keyValueStore = new GraphKeyValueStore(getDatabase());
PipelineSpecification specification = new PipelineSpecification("custom", StubTextProcessor.class.getName());
specification.setStopWords("hello,hihi");
specification.setThreadNumber(4);
try (Transaction tx = getDatabase().beginTx()) {
String writeValueAsString = mapper.writeValueAsString(specification);
keyValueStore.set("GA__NLP__PIPELINE_custom", writeValueAsString);
keyValueStore.set("GA__NLP__SETTING_fallbackLanguage", "en");
tx.success();
}
GraphAwareRuntime runtime = GraphAwareRuntimeFactory.createRuntime(getDatabase());
runtime.registerModule(new NLPModule("NLP", NLPConfiguration.defaultConfiguration(), getDatabase()));
runtime.start();
runtime.waitUntilStarted();
assertTrue(getStartedRuntime(getDatabase()).getModule(NLPModule.class).getNlpManager().getTextProcessorsManager().getTextProcessor(StubTextProcessor.class.getName()).getPipelines().contains("custom"));
assertTrue(getStartedRuntime(getDatabase()).getModule(NLPModule.class).getNlpManager().getConfiguration().hasSettingValue(SettingsConstants.FALLBACK_LANGUAGE));
}
use of com.graphaware.runtime.GraphAwareRuntime in project neo4j-nlp by graphaware.
the class NLPIntegrationTest method registerRuntime.
protected void registerRuntime() {
GraphAwareRuntime runtime = GraphAwareRuntimeFactory.createRuntime(getDatabase());
runtime.registerModule(new NLPModule("NLP", NLPConfiguration.defaultConfiguration(), getDatabase()));
runtime.start();
runtime.waitUntilStarted();
}
use of com.graphaware.runtime.GraphAwareRuntime in project neo4j-nlp-stanfordnlp by graphaware.
the class ProcedureTest method overallTest.
@Test
public void overallTest() {
GraphAwareRuntime gaRuntime = GraphAwareRuntimeFactory.createRuntime(getDatabase());
gaRuntime.registerModule(new NLPModule("NLP", NLPConfiguration.defaultConfiguration(), getDatabase()));
gaRuntime.start();
gaRuntime.waitUntilStarted();
// testAnnotatedText();
// clean();
// testAnnotatedTextWithSentiment();
// clean();
// testAnnotatedTextAndSentiment();
// clean();
// testAnnotatedTextOnMultiple();
// clean();
// testConceptText();
// clean();
// testLanguageDetection();
// clean();
// testSupportedLanguage();
// clean();
// testFilter();
// clean();
// testGetProceduresManagement();
// clean();
// testStopWords();
// testTextRank();
clean();
}
Aggregations