use of com.graphaware.nlp.util.TestNLPGraph in project neo4j-nlp by graphaware.
the class AnnotatedTextPersistenceTest method testAnnotatedTextWithSameTagInSameTextGotDifferentPOS.
@Test
public void testAnnotatedTextWithSameTagInSameTextGotDifferentPOS() {
clearDb();
TestNLPGraph test = new TestNLPGraph(getDatabase());
AnnotatedText annotatedText = createAnnotatedTextWithSameTagInSameTextWithDifferentPos();
try (Transaction tx = getDatabase().beginTx()) {
getNLPManager().getPersister(AnnotatedText.class).persist(annotatedText, "test", "1");
tx.success();
}
test.assertTagWithValueHasPos("cool", "cool0");
test.assertTagWithValueHasPos("cool", "cool1");
test.assertTagWithValueHasNE("cool", "NER_Cool0");
test.assertTagWithValueHasNE("cool", "NER_Cool1");
}
use of com.graphaware.nlp.util.TestNLPGraph in project neo4j-nlp by graphaware.
the class AnnotateTextProcedureTest method testTextAnnotationViaProcedure.
@Test
public void testTextAnnotationViaProcedure() {
clearDb();
executeInTransaction("CALL ga.nlp.annotate({pipeline:'tokenizer', text: 'hello my name is Frank', id: 'test-proc', checkLanguage: false})", emptyConsumer());
TestNLPGraph tester = new TestNLPGraph(getDatabase());
tester.assertAnnotatedTextNodesCount(1);
tester.assertSentenceNodesCount(1);
}
use of com.graphaware.nlp.util.TestNLPGraph in project neo4j-nlp by graphaware.
the class SentimentProcedureTest method testSentimentViaProcedure.
@Test
public void testSentimentViaProcedure() {
clearDb();
executeInTransaction("CALL ga.nlp.annotate({pipeline:'tokenizer', text: 'hello my name is Frank', id: 'test-proc', checkLanguage: false})", emptyConsumer());
executeInTransaction("MATCH (n:AnnotatedText) CALL ga.nlp.sentiment(n) YIELD result RETURN result", (result -> {
assertTrue(result.hasNext());
}));
TestNLPGraph tester = new TestNLPGraph(getDatabase());
tester.assertSentenceWithIdHasSentimentLabel("test-proc_0", Labels.VeryPositive.name());
}
use of com.graphaware.nlp.util.TestNLPGraph in project neo4j-nlp by graphaware.
the class TextRankProcedureTest method testTextRankPostProcessWithCustomInput.
@Test
public void testTextRankPostProcessWithCustomInput() throws Exception {
clearDb();
createGraph();
executeInTransaction("MATCH (n:AnnotatedText) CALL ga.nlp.ml.textRank({annotatedText: n, iterations: 30, damp: 0.85, threshold: 0.0001}) YIELD result RETURN result", (result -> {
assertTrue("ga.nlp.ml.textRank() procedure failed.", result.hasNext());
}));
executeInTransaction("MATCH (a:AnnotatedText)<-[:DESCRIBES]-(k:Keyword) WHERE k.value CONTAINS 'space shuttle' CALL ga.nlp.ml.textRank.postprocess({method:'subgroups', annotatedText: a}) YIELD result RETURN count(*)", emptyConsumer());
TestNLPGraph testNLPGraph = new TestNLPGraph(getDatabase());
testNLPGraph.debugKeywords();
executeInTransaction("MATCH (n:Keyword)-[:HAS_SUBGROUP]->(x) RETURN n.value AS v", (result -> {
assertTrue(result.hasNext());
while (result.hasNext()) {
System.out.println(result.next().get("v"));
}
}));
}
use of com.graphaware.nlp.util.TestNLPGraph in project neo4j-nlp by graphaware.
the class AnnotationPersistenceIntegrationTest method testLanguageIsDefaultedToNAWhenCheckLanguageIsFalseAndLanguageCouldNotBeDetected.
@Test
public void testLanguageIsDefaultedToNAWhenCheckLanguageIsFalseAndLanguageCouldNotBeDetected() {
try (Transaction tx = getDatabase().beginTx()) {
Node annotatedText = manager.annotateTextAndPersist("Barack Obama is born in Hawaii.", "123", StubTextProcessor.class.getName(), TextProcessor.DEFAULT_PIPELINE, false, false);
tx.success();
}
TestNLPGraph test = new TestNLPGraph(getDatabase());
test.assertTagWithIdExist("Barack_n/a");
test.assertTagWithIdExist("born_n/a");
}
Aggregations