Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 6836026

Browse files
committed
prepare release
1 parent 931b4fd commit 6836026

File tree

6 files changed

+78
-51
lines changed

6 files changed

+78
-51
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ MATCH (result)-[:CONTAINS_SENTENCE]->(s:Sentence)
6565
RETURN labels(s) as labels
6666
```
6767

68+
69+
70+
71+
## BETA
6872
### Customizing pipeline models
6973
To add new customized model (currenlty NER and Sentiment), one can do it via Cypher:
7074
```

pom.xml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.graphaware.neo4j</groupId>
66
<artifactId>nlp-opennlp</artifactId>
7-
<version>3.3.1.51.3-SNAPSHOT</version>
7+
<version>3.3.2.51.5-SNAPSHOT</version>
88

99
<licenses>
1010
<license>
@@ -14,6 +14,10 @@
1414
</license>
1515
</licenses>
1616

17+
<name>GraphAware OpenNLP Integration</name>
18+
<description>OpenNLP integration into GraphAware NLP</description>
19+
<url>https://graphaware.com</url>
20+
1721
<scm>
1822
<connection>scm:git:git@github.com:graphaware/neo4j-nlp-opennlp.git</connection>
1923
<developerConnection>scm:git:git@github.com:graphaware/neo4j-nlp-opennlp.git</developerConnection>
@@ -60,16 +64,17 @@
6064
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
6165
<maven.compiler.source>1.8</maven.compiler.source>
6266
<maven.compiler.target>1.8</maven.compiler.target>
63-
<graphaware.version>3.3.1.51</graphaware.version>
64-
<resttest.version>3.3.1.51.18</resttest.version>
65-
<neo4j.version>3.3.1</neo4j.version>
67+
<graphaware.version>3.3.2.51</graphaware.version>
68+
<resttest.version>3.3.2.51.18</resttest.version>
69+
<neo4j.version>3.3.2</neo4j.version>
70+
<nlp.version>3.3.2.51.4</nlp.version>
6671
</properties>
6772

6873
<dependencies>
6974
<dependency>
7075
<groupId>com.graphaware.neo4j</groupId>
7176
<artifactId>nlp</artifactId>
72-
<version>3.3.1.51.3-SNAPSHOT</version>
77+
<version>${nlp.version}</version>
7378
<scope>provided</scope>
7479
</dependency>
7580

@@ -135,7 +140,7 @@
135140
<dependency>
136141
<groupId>com.graphaware.neo4j</groupId>
137142
<artifactId>nlp</artifactId>
138-
<version>3.3.1.51.3-SNAPSHOT</version>
143+
<version>${nlp.version}</version>
139144
<type>test-jar</type>
140145
<scope>test</scope>
141146
</dependency>
@@ -221,7 +226,7 @@
221226
<artifactId>maven-surefire-plugin</artifactId>
222227
<version>2.20</version>
223228
<configuration>
224-
<argLine>-Xmx4g</argLine>
229+
<argLine>-Xmx8g</argLine>
225230
</configuration>
226231
</plugin>
227232
</plugins>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.graphaware.nlp.processor.opennlp;
2+
3+
import com.graphaware.nlp.NLPIntegrationTest;
4+
import com.graphaware.nlp.dsl.AbstractDSL;
5+
import org.neo4j.kernel.impl.proc.Procedures;
6+
import org.reflections.Reflections;
7+
8+
import java.util.Set;
9+
10+
public class OpenNLPIntegrationTest extends NLPIntegrationTest {
11+
12+
@Override
13+
protected void registerProceduresAndFunctions(Procedures procedures) throws Exception {
14+
super.registerProceduresAndFunctions(procedures);
15+
Reflections reflections = new Reflections("com.graphaware.nlp.dsl");
16+
Set<Class<? extends AbstractDSL>> cls = reflections.getSubTypesOf(AbstractDSL.class);
17+
for (Class c : cls) {
18+
procedures.registerProcedure(c);
19+
procedures.registerFunction(c);
20+
}
21+
}
22+
}

src/test/java/com/graphaware/nlp/processor/opennlp/TextProcessorTest.java

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import java.util.Collections;
2727
import java.util.HashMap;
2828
import java.util.Map;
29+
30+
import org.junit.BeforeClass;
2931
import org.junit.Test;
3032
import org.neo4j.graphdb.Node;
3133
import org.neo4j.graphdb.QueryExecutionException;
@@ -38,14 +40,19 @@
3840
import static org.junit.Assert.assertFalse;
3941
import static org.junit.Assert.assertNull;
4042

41-
public class TextProcessorTest extends EmbeddedDatabaseIntegrationTest {
43+
public class TextProcessorTest extends OpenNLPIntegrationTest {
4244

45+
private static TextProcessor textProcessor;
4346
private static final String TEXT_PROCESSOR = "com.graphaware.nlp.processor.opennlp.OpenNLPTextProcessor";
4447

48+
@BeforeClass
49+
public static void init() {
50+
textProcessor = ServiceLoader.loadTextProcessor(TEXT_PROCESSOR);
51+
textProcessor.init();
52+
}
53+
4554
@Test
4655
public void testAnnotatedText() {
47-
TextProcessor textProcessor = ServiceLoader.loadTextProcessor(TEXT_PROCESSOR);
48-
textProcessor.init();
4956
AnnotatedText annotatedText = textProcessor.annotateText("On 8 May 2013, "
5057
+ "one week before the Pakistani election, the third author, "
5158
+ "in his keynote address at the Sentiment Analysis Symposium, "
@@ -72,8 +79,6 @@ public void testAnnotatedText() {
7279

7380
@Test
7481
public void testLemmaLowerCasing() {
75-
TextProcessor textProcessor = ServiceLoader.loadTextProcessor(TEXT_PROCESSOR);
76-
textProcessor.init();
7782
AnnotatedText annotateText = textProcessor.annotateText("Collibra’s Data Governance Innovation: Enabling Data as a Strategic Asset", OpenNLPTextProcessor.TOKENIZER, "en", null);
7883

7984
assertEquals(1, annotateText.getSentences().size());
@@ -112,43 +117,39 @@ private ResourceIterator<Object> getTagsIterator(String value) throws QueryExecu
112117

113118
@Test
114119
public void testAnnotatedTag() {
115-
TextProcessor textProcessor = ServiceLoader.loadTextProcessor(TEXT_PROCESSOR);
116-
textProcessor.init();
117120
Tag annotateTag = textProcessor.annotateTag("winners", "en");
118121
assertEquals(annotateTag.getLemma(), "winner");
119122
}
120123

121-
@Test
122-
public void testAnnotationAndConcept() {
123-
// ConceptNet5Importer.Builder() - arguments need fixing
124-
/*TextProcessor textProcessor = ServiceLoader.loadTextProcessor("com.graphaware.nlp.processor.stanford.StanfordTextProcessor");
125-
ConceptNet5Importer conceptnet5Importer = new ConceptNet5Importer.Builder("http://conceptnet5.media.mit.edu/data/5.4", textProcessor)
126-
.build();
127-
String text = "Say hi to Christophe";
128-
AnnotatedText annotateText = textProcessor.annotateText(text, 1, 0, "en", false);
129-
List<Node> nodes = new ArrayList<>();
130-
try (Transaction beginTx = getDatabase().beginTx()) {
131-
Node annotatedNode = annotateText.storeOnGraph(getDatabase(), false);
132-
Map<String, Object> params = new HashMap<>();
133-
params.put("id", annotatedNode.getId());
134-
Result queryRes = getDatabase().execute("MATCH (n:AnnotatedText)-[*..2]->(t:Tag) where id(n) = {id} return t", params);
135-
ResourceIterator<Node> tags = queryRes.columnAs("t");
136-
while (tags.hasNext()) {
137-
Node tag = tags.next();
138-
nodes.add(tag);
139-
List<Tag> conceptTags = conceptnet5Importer.importHierarchy(Tag.createTag(tag), "en");
140-
conceptTags.stream().forEach((newTag) -> {
141-
nodes.add(newTag.storeOnGraph(getDatabase(), false));
142-
});
143-
}
144-
beginTx.success();
145-
}*/
146-
}
124+
// @Test
125+
// public void testAnnotationAndConcept() {
126+
// // ConceptNet5Importer.Builder() - arguments need fixing
127+
// /*TextProcessor textProcessor = ServiceLoader.loadTextProcessor("com.graphaware.nlp.processor.stanford.StanfordTextProcessor");
128+
// ConceptNet5Importer conceptnet5Importer = new ConceptNet5Importer.Builder("http://conceptnet5.media.mit.edu/data/5.4", textProcessor)
129+
// .build();
130+
// String text = "Say hi to Christophe";
131+
// AnnotatedText annotateText = textProcessor.annotateText(text, 1, 0, "en", false);
132+
// List<Node> nodes = new ArrayList<>();
133+
// try (Transaction beginTx = getDatabase().beginTx()) {
134+
// Node annotatedNode = annotateText.storeOnGraph(getDatabase(), false);
135+
// Map<String, Object> params = new HashMap<>();
136+
// params.put("id", annotatedNode.getId());
137+
// Result queryRes = getDatabase().execute("MATCH (n:AnnotatedText)-[*..2]->(t:Tag) where id(n) = {id} return t", params);
138+
// ResourceIterator<Node> tags = queryRes.columnAs("t");
139+
// while (tags.hasNext()) {
140+
// Node tag = tags.next();
141+
// nodes.add(tag);
142+
// List<Tag> conceptTags = conceptnet5Importer.importHierarchy(Tag.createTag(tag), "en");
143+
// conceptTags.stream().forEach((newTag) -> {
144+
// nodes.add(newTag.storeOnGraph(getDatabase(), false));
145+
// });
146+
// }
147+
// beginTx.success();
148+
// }*/
149+
// }
147150

148151
//@Test
149152
public void testSentiment() {
150-
TextProcessor textProcessor = ServiceLoader.loadTextProcessor(TEXT_PROCESSOR);
151-
152153
AnnotatedText annotateText = textProcessor.annotateText("I really hate to study at Stanford, it was a waste of time, I'll never be there again", OpenNLPTextProcessor.TOKENIZER, "en", null);
153154
assertEquals(1, annotateText.getSentences().size());
154155
assertEquals(0, annotateText.getSentences().get(0).getSentiment());
@@ -172,8 +173,6 @@ public void testSentiment() {
172173

173174
@Test
174175
public void testAnnotatedTextWithPosition() {
175-
TextProcessor textProcessor = ServiceLoader.loadTextProcessor(TEXT_PROCESSOR);
176-
textProcessor.init();
177176
AnnotatedText annotateText = textProcessor.annotateText("On 8 May 2013, "
178177
+ "one week before the Pakistani election, the third author, "
179178
+ "in his keynote address at the Sentiment Analysis Symposium, "
@@ -217,8 +216,6 @@ public void testAnnotatedTextWithPosition() {
217216

218217
@Test
219218
public void testAnnotatedShortText() {
220-
TextProcessor textProcessor = ServiceLoader.loadTextProcessor(TEXT_PROCESSOR);
221-
textProcessor.init();
222219
AnnotatedText annotateText = textProcessor.annotateText("Fixing Batch Endpoint Logging Problem", OpenNLPTextProcessor.TOKENIZER, "en", null);
223220

224221
assertEquals(1, annotateText.getSentences().size());
@@ -230,8 +227,6 @@ public void testAnnotatedShortText() {
230227

231228
@Test
232229
public void testAnnotatedShortText2() {
233-
TextProcessor textProcessor = ServiceLoader.loadTextProcessor(TEXT_PROCESSOR);
234-
textProcessor.init();
235230
AnnotatedText annotateText = textProcessor.annotateText("Importing CSV data does nothing", OpenNLPTextProcessor.TOKENIZER, "en", null);
236231
assertEquals(1, annotateText.getSentences().size());
237232
// GraphPersistence peristence = new LocalGraphDatabase(getDatabase());

src/test/java/com/graphaware/nlp/processor/opennlp/model/CustomSentimentModelIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.graphaware.nlp.processor.opennlp.model;
22

3-
import com.graphaware.nlp.NLPIntegrationTest;
3+
import com.graphaware.nlp.processor.opennlp.OpenNLPIntegrationTest;
44
import org.junit.Test;
55

66
import java.util.Map;
77

88
import static org.junit.Assert.*;
99

10-
public class CustomSentimentModelIntegrationTest extends NLPIntegrationTest {
10+
public class CustomSentimentModelIntegrationTest extends OpenNLPIntegrationTest {
1111

1212
@Test
1313
public void testTrainCustomModelWithProcedure() {

src/test/java/com/graphaware/nlp/processor/opennlp/procedure/ProcedureTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.graphaware.nlp.module.NLPConfiguration;
1919
import com.graphaware.nlp.module.NLPModule;
20+
import com.graphaware.nlp.processor.opennlp.OpenNLPIntegrationTest;
2021
import com.graphaware.runtime.GraphAwareRuntime;
2122
import com.graphaware.runtime.GraphAwareRuntimeFactory;
2223
import com.graphaware.test.integration.GraphAwareIntegrationTest;
@@ -32,7 +33,7 @@
3233
import org.neo4j.graphdb.Result;
3334
import org.neo4j.graphdb.Transaction;
3435

35-
public class ProcedureTest extends GraphAwareIntegrationTest {
36+
public class ProcedureTest extends OpenNLPIntegrationTest {
3637

3738

3839
private static final String TEXT = "On 8 May 2013, "

0 commit comments

Comments
 (0)