Skip to content

Commit

Permalink
The semgrex processing tool now sends back graph & pattern indices wh…
Browse files Browse the repository at this point in the history
…en processing semgrex results

Update CoreNLP.proto to include indices for semgrex results
  • Loading branch information
AngledLuffa committed Jul 21, 2022
1 parent 87d0bd2 commit 45b47e2
Show file tree
Hide file tree
Showing 6 changed files with 388 additions and 69 deletions.
Expand Up @@ -143,7 +143,7 @@ public void testSemgrexJson() throws IOException {

@Test
public void testSemgrexAnnotation() throws IOException {
String expected = "result { result { match { matchIndex: 3 node { name: \"verb\" matchIndex: 3 } node { name: \"obj\" matchIndex: 5 } } }}".replaceAll(" ", "");
String expected = "result { result { match { matchIndex: 3 node { name: \"verb\" matchIndex: 3 } node { name: \"obj\" matchIndex: 5 } graphIndex:0 semgrexIndex:0 } }}".replaceAll(" ", "");
String query = "The dog ate a fish";
byte[] message = query.getBytes("utf-8");
Properties props = new Properties();
Expand Down
17 changes: 14 additions & 3 deletions src/edu/stanford/nlp/pipeline/CoreNLP.proto
Expand Up @@ -627,6 +627,10 @@ message SemgrexRequest {
// If you pass in M semgrex expressions and N dependency graphs,
// this returns MxN nested results. Each SemgrexResult can match
// multiple times in one graph
//
// You may want to send multiple semgrexes per query because
// translating large numbers of dependency graphs to protobufs
// will be expensive, so doing several queries at once will save time
message SemgrexResponse {
message NamedNode {
required string name = 1;
Expand All @@ -639,9 +643,16 @@ message SemgrexResponse {
}

message Match {
required int32 matchIndex = 1;
repeated NamedNode node = 2;
repeated NamedRelation reln = 3;
required int32 matchIndex = 1;
repeated NamedNode node = 2;
repeated NamedRelation reln = 3;
// when processing multiple dependency graphs at once,
// which dependency graph this applies to
// indexed from 0
optional int32 graphIndex = 4;
// index of the semgrex expression this match applies to
// indexed from 0
optional int32 semgrexIndex = 5;
}

message SemgrexResult {
Expand Down

0 comments on commit 45b47e2

Please sign in to comment.