diff --git a/itest/src/edu/stanford/nlp/pipeline/StanfordCoreNLPServerITest.java b/itest/src/edu/stanford/nlp/pipeline/StanfordCoreNLPServerITest.java index b1b8fe2f03..15f1e303e8 100644 --- a/itest/src/edu/stanford/nlp/pipeline/StanfordCoreNLPServerITest.java +++ b/itest/src/edu/stanford/nlp/pipeline/StanfordCoreNLPServerITest.java @@ -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(); diff --git a/src/edu/stanford/nlp/pipeline/CoreNLP.proto b/src/edu/stanford/nlp/pipeline/CoreNLP.proto index ce5049f217..73535ede53 100644 --- a/src/edu/stanford/nlp/pipeline/CoreNLP.proto +++ b/src/edu/stanford/nlp/pipeline/CoreNLP.proto @@ -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; @@ -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 { diff --git a/src/edu/stanford/nlp/pipeline/CoreNLPProtos.java b/src/edu/stanford/nlp/pipeline/CoreNLPProtos.java index 55c7be3584..7f68919a62 100644 --- a/src/edu/stanford/nlp/pipeline/CoreNLPProtos.java +++ b/src/edu/stanford/nlp/pipeline/CoreNLPProtos.java @@ -71268,6 +71268,9 @@ edu.stanford.nlp.pipeline.CoreNLPProtos.SemgrexResponse.GraphResultOrBuilder get * 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 * * * Protobuf type {@code edu.stanford.nlp.pipeline.SemgrexResponse} @@ -72943,6 +72946,50 @@ edu.stanford.nlp.pipeline.CoreNLPProtos.SemgrexResponse.NamedNodeOrBuilder getNo */ edu.stanford.nlp.pipeline.CoreNLPProtos.SemgrexResponse.NamedRelationOrBuilder getRelnOrBuilder( int index); + + /** + *
+ * when processing multiple dependency graphs at once, + * which dependency graph this applies to + * indexed from 0 + *+ * + *
optional int32 graphIndex = 4;
+ * @return Whether the graphIndex field is set.
+ */
+ boolean hasGraphIndex();
+ /**
+ * + * when processing multiple dependency graphs at once, + * which dependency graph this applies to + * indexed from 0 + *+ * + *
optional int32 graphIndex = 4;
+ * @return The graphIndex.
+ */
+ int getGraphIndex();
+
+ /**
+ * + * index of the semgrex expression this match applies to + * indexed from 0 + *+ * + *
optional int32 semgrexIndex = 5;
+ * @return Whether the semgrexIndex field is set.
+ */
+ boolean hasSemgrexIndex();
+ /**
+ * + * index of the semgrex expression this match applies to + * indexed from 0 + *+ * + *
optional int32 semgrexIndex = 5;
+ * @return The semgrexIndex.
+ */
+ int getSemgrexIndex();
}
/**
* Protobuf type {@code edu.stanford.nlp.pipeline.SemgrexResponse.Match}
@@ -73015,6 +73062,16 @@ private Match(
input.readMessage(edu.stanford.nlp.pipeline.CoreNLPProtos.SemgrexResponse.NamedRelation.PARSER, extensionRegistry));
break;
}
+ case 32: {
+ bitField0_ |= 0x00000002;
+ graphIndex_ = input.readInt32();
+ break;
+ }
+ case 40: {
+ bitField0_ |= 0x00000004;
+ semgrexIndex_ = input.readInt32();
+ break;
+ }
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
@@ -73153,6 +73210,66 @@ public edu.stanford.nlp.pipeline.CoreNLPProtos.SemgrexResponse.NamedRelationOrBu
return reln_.get(index);
}
+ public static final int GRAPHINDEX_FIELD_NUMBER = 4;
+ private int graphIndex_;
+ /**
+ * + * when processing multiple dependency graphs at once, + * which dependency graph this applies to + * indexed from 0 + *+ * + *
optional int32 graphIndex = 4;
+ * @return Whether the graphIndex field is set.
+ */
+ @java.lang.Override
+ public boolean hasGraphIndex() {
+ return ((bitField0_ & 0x00000002) != 0);
+ }
+ /**
+ * + * when processing multiple dependency graphs at once, + * which dependency graph this applies to + * indexed from 0 + *+ * + *
optional int32 graphIndex = 4;
+ * @return The graphIndex.
+ */
+ @java.lang.Override
+ public int getGraphIndex() {
+ return graphIndex_;
+ }
+
+ public static final int SEMGREXINDEX_FIELD_NUMBER = 5;
+ private int semgrexIndex_;
+ /**
+ * + * index of the semgrex expression this match applies to + * indexed from 0 + *+ * + *
optional int32 semgrexIndex = 5;
+ * @return Whether the semgrexIndex field is set.
+ */
+ @java.lang.Override
+ public boolean hasSemgrexIndex() {
+ return ((bitField0_ & 0x00000004) != 0);
+ }
+ /**
+ * + * index of the semgrex expression this match applies to + * indexed from 0 + *+ * + *
optional int32 semgrexIndex = 5;
+ * @return The semgrexIndex.
+ */
+ @java.lang.Override
+ public int getSemgrexIndex() {
+ return semgrexIndex_;
+ }
+
private byte memoizedIsInitialized = -1;
@java.lang.Override
public final boolean isInitialized() {
@@ -73192,6 +73309,12 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
for (int i = 0; i < reln_.size(); i++) {
output.writeMessage(3, reln_.get(i));
}
+ if (((bitField0_ & 0x00000002) != 0)) {
+ output.writeInt32(4, graphIndex_);
+ }
+ if (((bitField0_ & 0x00000004) != 0)) {
+ output.writeInt32(5, semgrexIndex_);
+ }
unknownFields.writeTo(output);
}
@@ -73213,6 +73336,14 @@ public int getSerializedSize() {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(3, reln_.get(i));
}
+ if (((bitField0_ & 0x00000002) != 0)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(4, graphIndex_);
+ }
+ if (((bitField0_ & 0x00000004) != 0)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(5, semgrexIndex_);
+ }
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
@@ -73237,6 +73368,16 @@ public boolean equals(final java.lang.Object obj) {
.equals(other.getNodeList())) return false;
if (!getRelnList()
.equals(other.getRelnList())) return false;
+ if (hasGraphIndex() != other.hasGraphIndex()) return false;
+ if (hasGraphIndex()) {
+ if (getGraphIndex()
+ != other.getGraphIndex()) return false;
+ }
+ if (hasSemgrexIndex() != other.hasSemgrexIndex()) return false;
+ if (hasSemgrexIndex()) {
+ if (getSemgrexIndex()
+ != other.getSemgrexIndex()) return false;
+ }
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
@@ -73260,6 +73401,14 @@ public int hashCode() {
hash = (37 * hash) + RELN_FIELD_NUMBER;
hash = (53 * hash) + getRelnList().hashCode();
}
+ if (hasGraphIndex()) {
+ hash = (37 * hash) + GRAPHINDEX_FIELD_NUMBER;
+ hash = (53 * hash) + getGraphIndex();
+ }
+ if (hasSemgrexIndex()) {
+ hash = (37 * hash) + SEMGREXINDEX_FIELD_NUMBER;
+ hash = (53 * hash) + getSemgrexIndex();
+ }
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
@@ -73409,6 +73558,10 @@ public Builder clear() {
} else {
relnBuilder_.clear();
}
+ graphIndex_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000008);
+ semgrexIndex_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000010);
return this;
}
@@ -73459,6 +73612,14 @@ public edu.stanford.nlp.pipeline.CoreNLPProtos.SemgrexResponse.Match buildPartia
} else {
result.reln_ = relnBuilder_.build();
}
+ if (((from_bitField0_ & 0x00000008) != 0)) {
+ result.graphIndex_ = graphIndex_;
+ to_bitField0_ |= 0x00000002;
+ }
+ if (((from_bitField0_ & 0x00000010) != 0)) {
+ result.semgrexIndex_ = semgrexIndex_;
+ to_bitField0_ |= 0x00000004;
+ }
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
@@ -73563,6 +73724,12 @@ public Builder mergeFrom(edu.stanford.nlp.pipeline.CoreNLPProtos.SemgrexResponse
}
}
}
+ if (other.hasGraphIndex()) {
+ setGraphIndex(other.getGraphIndex());
+ }
+ if (other.hasSemgrexIndex()) {
+ setSemgrexIndex(other.getSemgrexIndex());
+ }
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
@@ -74124,6 +74291,128 @@ public edu.stanford.nlp.pipeline.CoreNLPProtos.SemgrexResponse.NamedRelation.Bui
}
return relnBuilder_;
}
+
+ private int graphIndex_ ;
+ /**
+ * + * when processing multiple dependency graphs at once, + * which dependency graph this applies to + * indexed from 0 + *+ * + *
optional int32 graphIndex = 4;
+ * @return Whether the graphIndex field is set.
+ */
+ @java.lang.Override
+ public boolean hasGraphIndex() {
+ return ((bitField0_ & 0x00000008) != 0);
+ }
+ /**
+ * + * when processing multiple dependency graphs at once, + * which dependency graph this applies to + * indexed from 0 + *+ * + *
optional int32 graphIndex = 4;
+ * @return The graphIndex.
+ */
+ @java.lang.Override
+ public int getGraphIndex() {
+ return graphIndex_;
+ }
+ /**
+ * + * when processing multiple dependency graphs at once, + * which dependency graph this applies to + * indexed from 0 + *+ * + *
optional int32 graphIndex = 4;
+ * @param value The graphIndex to set.
+ * @return This builder for chaining.
+ */
+ public Builder setGraphIndex(int value) {
+ bitField0_ |= 0x00000008;
+ graphIndex_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * + * when processing multiple dependency graphs at once, + * which dependency graph this applies to + * indexed from 0 + *+ * + *
optional int32 graphIndex = 4;
+ * @return This builder for chaining.
+ */
+ public Builder clearGraphIndex() {
+ bitField0_ = (bitField0_ & ~0x00000008);
+ graphIndex_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private int semgrexIndex_ ;
+ /**
+ * + * index of the semgrex expression this match applies to + * indexed from 0 + *+ * + *
optional int32 semgrexIndex = 5;
+ * @return Whether the semgrexIndex field is set.
+ */
+ @java.lang.Override
+ public boolean hasSemgrexIndex() {
+ return ((bitField0_ & 0x00000010) != 0);
+ }
+ /**
+ * + * index of the semgrex expression this match applies to + * indexed from 0 + *+ * + *
optional int32 semgrexIndex = 5;
+ * @return The semgrexIndex.
+ */
+ @java.lang.Override
+ public int getSemgrexIndex() {
+ return semgrexIndex_;
+ }
+ /**
+ * + * index of the semgrex expression this match applies to + * indexed from 0 + *+ * + *
optional int32 semgrexIndex = 5;
+ * @param value The semgrexIndex to set.
+ * @return This builder for chaining.
+ */
+ public Builder setSemgrexIndex(int value) {
+ bitField0_ |= 0x00000010;
+ semgrexIndex_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * + * index of the semgrex expression this match applies to + * indexed from 0 + *+ * + *
optional int32 semgrexIndex = 5;
+ * @return This builder for chaining.
+ */
+ public Builder clearSemgrexIndex() {
+ bitField0_ = (bitField0_ & ~0x00000010);
+ semgrexIndex_ = 0;
+ onChanged();
+ return this;
+ }
@java.lang.Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
@@ -75994,6 +76283,9 @@ protected Builder newBuilderForType(
* 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
*
*
* Protobuf type {@code edu.stanford.nlp.pipeline.SemgrexResponse}
@@ -89697,68 +89989,69 @@ public edu.stanford.nlp.pipeline.CoreNLPProtos.TsurgeonResponse getDefaultInstan
"ncies\032z\n\014Dependencies\022/\n\005token\030\001 \003(\0132 .e" +
"du.stanford.nlp.pipeline.Token\0229\n\005graph\030" +
"\002 \002(\0132*.edu.stanford.nlp.pipeline.Depend" +
- "encyGraph\"\212\004\n\017SemgrexResponse\022F\n\006result\030" +
+ "encyGraph\"\264\004\n\017SemgrexResponse\022F\n\006result\030" +
"\001 \003(\01326.edu.stanford.nlp.pipeline.Semgre" +
"xResponse.GraphResult\032-\n\tNamedNode\022\014\n\004na" +
"me\030\001 \002(\t\022\022\n\nmatchIndex\030\002 \002(\005\032+\n\rNamedRel" +
- "ation\022\014\n\004name\030\001 \002(\t\022\014\n\004reln\030\002 \002(\t\032\247\001\n\005Ma" +
+ "ation\022\014\n\004name\030\001 \002(\t\022\014\n\004reln\030\002 \002(\t\032\321\001\n\005Ma" +
"tch\022\022\n\nmatchIndex\030\001 \002(\005\022B\n\004node\030\002 \003(\01324." +
"edu.stanford.nlp.pipeline.SemgrexRespons" +
"e.NamedNode\022F\n\004reln\030\003 \003(\01328.edu.stanford" +
".nlp.pipeline.SemgrexResponse.NamedRelat" +
- "ion\032P\n\rSemgrexResult\022?\n\005match\030\001 \003(\01320.ed" +
- "u.stanford.nlp.pipeline.SemgrexResponse." +
- "Match\032W\n\013GraphResult\022H\n\006result\030\001 \003(\01328.e" +
- "du.stanford.nlp.pipeline.SemgrexResponse" +
- ".SemgrexResult\"W\n\022TokensRegexRequest\0220\n\003" +
- "doc\030\001 \002(\0132#.edu.stanford.nlp.pipeline.Do" +
- "cument\022\017\n\007pattern\030\002 \003(\t\"\247\003\n\023TokensRegexR" +
- "esponse\022J\n\005match\030\001 \003(\0132;.edu.stanford.nl" +
- "p.pipeline.TokensRegexResponse.PatternMa" +
- "tch\0329\n\rMatchLocation\022\014\n\004text\030\001 \001(\t\022\r\n\005be" +
- "gin\030\002 \001(\005\022\013\n\003end\030\003 \001(\005\032\263\001\n\005Match\022\020\n\010sent" +
- "ence\030\001 \002(\005\022K\n\005match\030\002 \002(\0132<.edu.stanford" +
- ".nlp.pipeline.TokensRegexResponse.MatchL" +
- "ocation\022K\n\005group\030\003 \003(\0132<.edu.stanford.nl" +
- "p.pipeline.TokensRegexResponse.MatchLoca" +
- "tion\032S\n\014PatternMatch\022C\n\005match\030\001 \003(\01324.ed" +
- "u.stanford.nlp.pipeline.TokensRegexRespo" +
- "nse.Match\"\256\001\n\031DependencyEnhancerRequest\022" +
- "5\n\010document\030\001 \002(\0132#.edu.stanford.nlp.pip" +
- "eline.Document\0227\n\010language\030\002 \001(\0162#.edu.s" +
- "tanford.nlp.pipeline.LanguageH\000\022\032\n\020relat" +
- "ivePronouns\030\003 \001(\tH\000B\005\n\003ref\"\264\001\n\022Flattened" +
- "ParseTree\022A\n\005nodes\030\001 \003(\01322.edu.stanford." +
- "nlp.pipeline.FlattenedParseTree.Node\032[\n\004" +
- "Node\022\022\n\010openNode\030\001 \001(\010H\000\022\023\n\tcloseNode\030\002 " +
- "\001(\010H\000\022\017\n\005value\030\003 \001(\tH\000\022\r\n\005score\030\004 \001(\001B\n\n" +
- "\010contents\"\366\001\n\025EvaluateParserRequest\022N\n\010t" +
- "reebank\030\001 \003(\0132<.edu.stanford.nlp.pipelin" +
- "e.EvaluateParserRequest.ParseResult\032\214\001\n\013" +
- "ParseResult\022;\n\004gold\030\001 \002(\0132-.edu.stanford" +
- ".nlp.pipeline.FlattenedParseTree\022@\n\tpred" +
- "icted\030\002 \003(\0132-.edu.stanford.nlp.pipeline." +
- "FlattenedParseTree\"5\n\026EvaluateParserResp" +
- "onse\022\n\n\002f1\030\001 \002(\001\022\017\n\007kbestF1\030\002 \001(\001\"\310\001\n\017Ts" +
- "urgeonRequest\022H\n\noperations\030\001 \003(\01324.edu." +
- "stanford.nlp.pipeline.TsurgeonRequest.Op" +
- "eration\022<\n\005trees\030\002 \003(\0132-.edu.stanford.nl" +
- "p.pipeline.FlattenedParseTree\032-\n\tOperati" +
- "on\022\016\n\006tregex\030\001 \002(\t\022\020\n\010tsurgeon\030\002 \003(\t\"P\n\020" +
- "TsurgeonResponse\022<\n\005trees\030\001 \003(\0132-.edu.st" +
- "anford.nlp.pipeline.FlattenedParseTree*\243" +
- "\001\n\010Language\022\013\n\007Unknown\020\000\022\007\n\003Any\020\001\022\n\n\006Ara" +
- "bic\020\002\022\013\n\007Chinese\020\003\022\013\n\007English\020\004\022\n\n\006Germa" +
- "n\020\005\022\n\n\006French\020\006\022\n\n\006Hebrew\020\007\022\013\n\007Spanish\020\010" +
- "\022\024\n\020UniversalEnglish\020\t\022\024\n\020UniversalChine" +
- "se\020\n*h\n\tSentiment\022\023\n\017STRONG_NEGATIVE\020\000\022\021" +
- "\n\rWEAK_NEGATIVE\020\001\022\013\n\007NEUTRAL\020\002\022\021\n\rWEAK_P" +
- "OSITIVE\020\003\022\023\n\017STRONG_POSITIVE\020\004*\223\001\n\024Natur" +
- "alLogicRelation\022\017\n\013EQUIVALENCE\020\000\022\026\n\022FORW" +
- "ARD_ENTAILMENT\020\001\022\026\n\022REVERSE_ENTAILMENT\020\002" +
- "\022\014\n\010NEGATION\020\003\022\017\n\013ALTERNATION\020\004\022\t\n\005COVER" +
- "\020\005\022\020\n\014INDEPENDENCE\020\006B*\n\031edu.stanford.nlp" +
- ".pipelineB\rCoreNLPProtos"
+ "ion\022\022\n\ngraphIndex\030\004 \001(\005\022\024\n\014semgrexIndex\030" +
+ "\005 \001(\005\032P\n\rSemgrexResult\022?\n\005match\030\001 \003(\01320." +
+ "edu.stanford.nlp.pipeline.SemgrexRespons" +
+ "e.Match\032W\n\013GraphResult\022H\n\006result\030\001 \003(\01328" +
+ ".edu.stanford.nlp.pipeline.SemgrexRespon" +
+ "se.SemgrexResult\"W\n\022TokensRegexRequest\0220" +
+ "\n\003doc\030\001 \002(\0132#.edu.stanford.nlp.pipeline." +
+ "Document\022\017\n\007pattern\030\002 \003(\t\"\247\003\n\023TokensRege" +
+ "xResponse\022J\n\005match\030\001 \003(\0132;.edu.stanford." +
+ "nlp.pipeline.TokensRegexResponse.Pattern" +
+ "Match\0329\n\rMatchLocation\022\014\n\004text\030\001 \001(\t\022\r\n\005" +
+ "begin\030\002 \001(\005\022\013\n\003end\030\003 \001(\005\032\263\001\n\005Match\022\020\n\010se" +
+ "ntence\030\001 \002(\005\022K\n\005match\030\002 \002(\0132<.edu.stanfo" +
+ "rd.nlp.pipeline.TokensRegexResponse.Matc" +
+ "hLocation\022K\n\005group\030\003 \003(\0132<.edu.stanford." +
+ "nlp.pipeline.TokensRegexResponse.MatchLo" +
+ "cation\032S\n\014PatternMatch\022C\n\005match\030\001 \003(\01324." +
+ "edu.stanford.nlp.pipeline.TokensRegexRes" +
+ "ponse.Match\"\256\001\n\031DependencyEnhancerReques" +
+ "t\0225\n\010document\030\001 \002(\0132#.edu.stanford.nlp.p" +
+ "ipeline.Document\0227\n\010language\030\002 \001(\0162#.edu" +
+ ".stanford.nlp.pipeline.LanguageH\000\022\032\n\020rel" +
+ "ativePronouns\030\003 \001(\tH\000B\005\n\003ref\"\264\001\n\022Flatten" +
+ "edParseTree\022A\n\005nodes\030\001 \003(\01322.edu.stanfor" +
+ "d.nlp.pipeline.FlattenedParseTree.Node\032[" +
+ "\n\004Node\022\022\n\010openNode\030\001 \001(\010H\000\022\023\n\tcloseNode\030" +
+ "\002 \001(\010H\000\022\017\n\005value\030\003 \001(\tH\000\022\r\n\005score\030\004 \001(\001B" +
+ "\n\n\010contents\"\366\001\n\025EvaluateParserRequest\022N\n" +
+ "\010treebank\030\001 \003(\0132<.edu.stanford.nlp.pipel" +
+ "ine.EvaluateParserRequest.ParseResult\032\214\001" +
+ "\n\013ParseResult\022;\n\004gold\030\001 \002(\0132-.edu.stanfo" +
+ "rd.nlp.pipeline.FlattenedParseTree\022@\n\tpr" +
+ "edicted\030\002 \003(\0132-.edu.stanford.nlp.pipelin" +
+ "e.FlattenedParseTree\"5\n\026EvaluateParserRe" +
+ "sponse\022\n\n\002f1\030\001 \002(\001\022\017\n\007kbestF1\030\002 \001(\001\"\310\001\n\017" +
+ "TsurgeonRequest\022H\n\noperations\030\001 \003(\01324.ed" +
+ "u.stanford.nlp.pipeline.TsurgeonRequest." +
+ "Operation\022<\n\005trees\030\002 \003(\0132-.edu.stanford." +
+ "nlp.pipeline.FlattenedParseTree\032-\n\tOpera" +
+ "tion\022\016\n\006tregex\030\001 \002(\t\022\020\n\010tsurgeon\030\002 \003(\t\"P" +
+ "\n\020TsurgeonResponse\022<\n\005trees\030\001 \003(\0132-.edu." +
+ "stanford.nlp.pipeline.FlattenedParseTree" +
+ "*\243\001\n\010Language\022\013\n\007Unknown\020\000\022\007\n\003Any\020\001\022\n\n\006A" +
+ "rabic\020\002\022\013\n\007Chinese\020\003\022\013\n\007English\020\004\022\n\n\006Ger" +
+ "man\020\005\022\n\n\006French\020\006\022\n\n\006Hebrew\020\007\022\013\n\007Spanish" +
+ "\020\010\022\024\n\020UniversalEnglish\020\t\022\024\n\020UniversalChi" +
+ "nese\020\n*h\n\tSentiment\022\023\n\017STRONG_NEGATIVE\020\000" +
+ "\022\021\n\rWEAK_NEGATIVE\020\001\022\013\n\007NEUTRAL\020\002\022\021\n\rWEAK" +
+ "_POSITIVE\020\003\022\023\n\017STRONG_POSITIVE\020\004*\223\001\n\024Nat" +
+ "uralLogicRelation\022\017\n\013EQUIVALENCE\020\000\022\026\n\022FO" +
+ "RWARD_ENTAILMENT\020\001\022\026\n\022REVERSE_ENTAILMENT" +
+ "\020\002\022\014\n\010NEGATION\020\003\022\017\n\013ALTERNATION\020\004\022\t\n\005COV" +
+ "ER\020\005\022\020\n\014INDEPENDENCE\020\006B*\n\031edu.stanford.n" +
+ "lp.pipelineB\rCoreNLPProtos"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
@@ -89955,7 +90248,7 @@ public edu.stanford.nlp.pipeline.CoreNLPProtos.TsurgeonResponse getDefaultInstan
internal_static_edu_stanford_nlp_pipeline_SemgrexResponse_Match_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_edu_stanford_nlp_pipeline_SemgrexResponse_Match_descriptor,
- new java.lang.String[] { "MatchIndex", "Node", "Reln", });
+ new java.lang.String[] { "MatchIndex", "Node", "Reln", "GraphIndex", "SemgrexIndex", });
internal_static_edu_stanford_nlp_pipeline_SemgrexResponse_SemgrexResult_descriptor =
internal_static_edu_stanford_nlp_pipeline_SemgrexResponse_descriptor.getNestedTypes().get(3);
internal_static_edu_stanford_nlp_pipeline_SemgrexResponse_SemgrexResult_fieldAccessorTable = new
diff --git a/src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java b/src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java
index f9bf29565a..d8708a904b 100644
--- a/src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java
+++ b/src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java
@@ -1219,11 +1219,13 @@ public void handle(HttpExchange httpExchange) throws IOException {
}
CoreNLPProtos.SemgrexResponse.Builder responseBuilder = CoreNLPProtos.SemgrexResponse.newBuilder();
+ int sentenceIdx = 0;
for (CoreMap sentence : doc.get(CoreAnnotations.SentencesAnnotation.class)) {
SemanticGraph graph = sentence.get(dependenciesType.annotation());
CoreNLPProtos.SemgrexResponse.GraphResult.Builder graphResultBuilder = CoreNLPProtos.SemgrexResponse.GraphResult.newBuilder();
- graphResultBuilder.addResult(ProcessSemgrexRequest.matchSentence(regex, graph));
+ graphResultBuilder.addResult(ProcessSemgrexRequest.matchSentence(regex, graph, 0, sentenceIdx));
responseBuilder.addResult(graphResultBuilder.build());
+ ++sentenceIdx;
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
diff --git a/src/edu/stanford/nlp/semgraph/semgrex/ProcessSemgrexRequest.java b/src/edu/stanford/nlp/semgraph/semgrex/ProcessSemgrexRequest.java
index 7b2ba0abde..f862eaf139 100644
--- a/src/edu/stanford/nlp/semgraph/semgrex/ProcessSemgrexRequest.java
+++ b/src/edu/stanford/nlp/semgraph/semgrex/ProcessSemgrexRequest.java
@@ -25,12 +25,14 @@ public class ProcessSemgrexRequest extends ProcessProtobufRequest {
/**
* Builds a single inner SemgrexResult structure from the pair of a SemgrexPattern and a SemanticGraph
*/
- public static CoreNLPProtos.SemgrexResponse.SemgrexResult matchSentence(SemgrexPattern pattern, SemanticGraph graph) {
+ public static CoreNLPProtos.SemgrexResponse.SemgrexResult matchSentence(SemgrexPattern pattern, SemanticGraph graph, int patternIdx, int graphIdx) {
CoreNLPProtos.SemgrexResponse.SemgrexResult.Builder semgrexResultBuilder = CoreNLPProtos.SemgrexResponse.SemgrexResult.newBuilder();
SemgrexMatcher matcher = pattern.matcher(graph);
while (matcher.find()) {
CoreNLPProtos.SemgrexResponse.Match.Builder matchBuilder = CoreNLPProtos.SemgrexResponse.Match.newBuilder();
matchBuilder.setMatchIndex(matcher.getMatch().index());
+ matchBuilder.setSemgrexIndex(patternIdx);
+ matchBuilder.setGraphIndex(graphIdx);
for (String nodeName : matcher.getNodeNames()) {
CoreNLPProtos.SemgrexResponse.NamedNode.Builder nodeBuilder = CoreNLPProtos.SemgrexResponse.NamedNode.newBuilder();
@@ -61,16 +63,20 @@ public static CoreNLPProtos.SemgrexResponse processRequest(CoreNLPProtos.Semgrex
CoreNLPProtos.SemgrexResponse.Builder responseBuilder = CoreNLPProtos.SemgrexResponse.newBuilder();
List