use of com.graphaware.nlp.dsl.request.PipelineSpecification in project neo4j-nlp by graphaware.
the class DynamicConfigurationTest method testConfigurationCanRemovePipeline.
@Test
public void testConfigurationCanRemovePipeline() {
DynamicConfiguration configuration = new DynamicConfiguration(getDatabase());
PipelineSpecification specification = new PipelineSpecification("custom", StubTextProcessor.class.getName());
specification.setStopWords("hello,hihi");
specification.setThreadNumber(4);
configuration.storeCustomPipeline(specification);
try (Transaction tx = getDatabase().beginTx()) {
assertTrue(keyValueStore.hasKey("GA__NLP__PIPELINE_custom"));
configuration.removePipeline("custom", StubTextProcessor.class.getName());
assertFalse(keyValueStore.hasKey("GA__NLP__PIPELINE_custom"));
tx.success();
}
}
use of com.graphaware.nlp.dsl.request.PipelineSpecification in project neo4j-nlp by graphaware.
the class TextProcessorsProcedureTest method testCustomPipelineWithSentimentModelShouldDisplayModelNameInPipelineInfo.
@Test
public void testCustomPipelineWithSentimentModelShouldDisplayModelNameInPipelineInfo() {
clearDb();
removeCustomPipelines();
executeInTransaction("CALL ga.nlp.processor.addPipeline({name:'custom-1', textProcessor:'" + StubTextProcessor.class.getName() + "', processingSteps:{customSentiment:'my-model'}})", emptyConsumer());
PipelineSpecification pipelineSpecification = getNLPManager().getConfiguration().loadPipeline("custom-1");
assertEquals("my-model", pipelineSpecification.getProcessingStepAsString("customSentiment"));
executeInTransaction("CALL ga.nlp.processor.getPipelines('custom-1')", (result -> {
assertTrue(result.hasNext());
while (result.hasNext()) {
Map<String, Object> record = result.next();
System.out.println(record);
Map<String, Object> specs = (Map<String, Object>) record.get("processingSteps");
assertEquals("my-model", specs.get("customSentiment"));
}
}));
}
use of com.graphaware.nlp.dsl.request.PipelineSpecification in project neo4j-nlp by graphaware.
the class TextProcessorsProcedureTest method testAddingPipelineWithCustomSentimentModel.
@Test
public void testAddingPipelineWithCustomSentimentModel() {
clearDb();
removeCustomPipelines();
executeInTransaction("CALL ga.nlp.processor.addPipeline({name:'custom-1', textProcessor:'" + StubTextProcessor.class.getName() + "', processingSteps:{customSentiment:'my-model'}})", emptyConsumer());
PipelineSpecification pipelineSpecification = getNLPManager().getConfiguration().loadPipeline("custom-1");
assertEquals("my-model", pipelineSpecification.getProcessingStepAsString("customSentiment"));
}
use of com.graphaware.nlp.dsl.request.PipelineSpecification in project neo4j-nlp by graphaware.
the class TextProcessorsProcedureTest method testAddPipeline.
@Test
public void testAddPipeline() {
clearDb();
executeInTransaction("CALL ga.nlp.processor.addPipeline({name:'custom-1', textProcessor:'" + StubTextProcessor.class.getName() + "', processingSteps:{tokenize:true,ner:true,dependency:true},excludedNER:['MONEY','MISC']})", emptyConsumer());
assertTrue(checkConfigurationContainsKey(STORE_KEY + "PIPELINE_custom-1"));
PipelineSpecification pipelineSpecification = getNLPManager().getConfiguration().loadPipeline("custom-1");
assertNotNull(pipelineSpecification);
assertTrue(pipelineSpecification.hasProcessingStep("tokenize"));
assertTrue(pipelineSpecification.hasProcessingStep("dependency"));
assertTrue(pipelineSpecification.getExcludedNER().contains("MONEY"));
assertTrue(pipelineSpecification.getExcludedNER().contains("MISC"));
}
use of com.graphaware.nlp.dsl.request.PipelineSpecification in project neo4j-nlp by graphaware.
the class TextProcessorsProcedureTest method testAddPipelineWithCustomWhiteList.
@Test
public void testAddPipelineWithCustomWhiteList() {
clearDb();
executeInTransaction("CALL ga.nlp.processor.addPipeline({name:'custom-1', textProcessor:'" + StubTextProcessor.class.getName() + "', whitelist:'hello,i,be,work,IBM,ibm', processingSteps:{tokenize:true,ner:true,dependency:true},excludedNER:['MONEY','MISC']})", emptyConsumer());
assertTrue(checkConfigurationContainsKey(STORE_KEY + "PIPELINE_custom-1"));
PipelineSpecification pipelineSpecification = getNLPManager().getConfiguration().loadPipeline("custom-1");
assertEquals("hello,i,be,work,IBM,ibm", pipelineSpecification.getWhitelist());
}
Aggregations