Skip to content

Commit 45b47e2

Browse files
committed
The semgrex processing tool now sends back graph & pattern indices when processing semgrex results
Update CoreNLP.proto to include indices for semgrex results
1 parent 87d0bd2 commit 45b47e2

File tree

6 files changed

+388
-69
lines changed

6 files changed

+388
-69
lines changed

itest/src/edu/stanford/nlp/pipeline/StanfordCoreNLPServerITest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void testSemgrexJson() throws IOException {
143143

144144
@Test
145145
public void testSemgrexAnnotation() throws IOException {
146-
String expected = "result { result { match { matchIndex: 3 node { name: \"verb\" matchIndex: 3 } node { name: \"obj\" matchIndex: 5 } } }}".replaceAll(" ", "");
146+
String expected = "result { result { match { matchIndex: 3 node { name: \"verb\" matchIndex: 3 } node { name: \"obj\" matchIndex: 5 } graphIndex:0 semgrexIndex:0 } }}".replaceAll(" ", "");
147147
String query = "The dog ate a fish";
148148
byte[] message = query.getBytes("utf-8");
149149
Properties props = new Properties();

src/edu/stanford/nlp/pipeline/CoreNLP.proto

+14-3
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,10 @@ message SemgrexRequest {
627627
// If you pass in M semgrex expressions and N dependency graphs,
628628
// this returns MxN nested results. Each SemgrexResult can match
629629
// multiple times in one graph
630+
//
631+
// You may want to send multiple semgrexes per query because
632+
// translating large numbers of dependency graphs to protobufs
633+
// will be expensive, so doing several queries at once will save time
630634
message SemgrexResponse {
631635
message NamedNode {
632636
required string name = 1;
@@ -639,9 +643,16 @@ message SemgrexResponse {
639643
}
640644

641645
message Match {
642-
required int32 matchIndex = 1;
643-
repeated NamedNode node = 2;
644-
repeated NamedRelation reln = 3;
646+
required int32 matchIndex = 1;
647+
repeated NamedNode node = 2;
648+
repeated NamedRelation reln = 3;
649+
// when processing multiple dependency graphs at once,
650+
// which dependency graph this applies to
651+
// indexed from 0
652+
optional int32 graphIndex = 4;
653+
// index of the semgrex expression this match applies to
654+
// indexed from 0
655+
optional int32 semgrexIndex = 5;
645656
}
646657

647658
message SemgrexResult {

0 commit comments

Comments
 (0)