Skip to content

Commit 12dfb70

Browse files
committed
Merge branch 'dev' of github.com:stanfordnlp/CoreNLP into dev
2 parents 9f1b015 + 1ef9ef9 commit 12dfb70

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/edu/stanford/nlp/scenegraph/RuleBasedParser.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
public class RuleBasedParser extends AbstractSceneGraphParser {
2222

2323
/* A man is riding a horse. */
24-
public static SemgrexPattern SUBJ_PRED_OBJ_TRIPLET_PATTERN = SemgrexPattern.compile("{}=pred >nsubj {tag:/NNP?S?/}=subj >/(iobj|dobj|nmod:.*)/=objreln {tag:/NNP?S?/}=obj !> cop {}");
24+
public static SemgrexPattern SUBJ_PRED_OBJ_TRIPLET_PATTERN = SemgrexPattern.compile("{}=pred >nsubj {tag:/NNP?S?/}=subj >/(iobj|obj|nmod:.*|obl:.*)/=objreln {tag:/NNP?S?/}=obj !> cop {}");
2525

2626
/* A woman is smiling. */
27-
public static SemgrexPattern SUBJ_PRED_PAIR_PATTERN = SemgrexPattern.compile("{}=pred >nsubj {tag:/NNP?S?/}=subj !>/(iobj|dobj|nmod:.*)/ {tag:/NNP?S?/} !>cop {}");
27+
public static SemgrexPattern SUBJ_PRED_PAIR_PATTERN = SemgrexPattern.compile("{}=pred >nsubj {tag:/NNP?S?/}=subj !>/(iobj|obj|nmod:.*|obl:.*)/ {tag:/NNP?S?/} !>cop {}");
2828

2929
/* The man is a rider. */
3030
public static SemgrexPattern COPULAR_PATTERN = SemgrexPattern.compile("{}=pred >nsubj {tag:/NNP?S?/}=subj >cop {}");
@@ -36,16 +36,16 @@ public class RuleBasedParser extends AbstractSceneGraphParser {
3636
public static SemgrexPattern ADJ_PRED_PATTERN = SemgrexPattern.compile("{tag:/J.*/}=adj >nsubj {}=obj");
3737

3838
/* A woman is in the house. */
39-
public static SemgrexPattern PP_MOD_PATTERN = SemgrexPattern.compile("{tag:/NNP?S?/}=gov >/nmod:.*/=reln {}=mod");
39+
public static SemgrexPattern PP_MOD_PATTERN = SemgrexPattern.compile("{tag:/NNP?S?/}=gov >/(nmod:.*|obl:.*)/=reln {}=mod");
4040

4141
/* His watch. */
4242
public static SemgrexPattern POSS_PATTERN = SemgrexPattern.compile("{tag:/NNP?S?/}=gov >/nmod:poss/=reln {tag:/NNP?S?/}=mod");
4343

4444
/* */
45-
public static SemgrexPattern AGENT_PATTERN = SemgrexPattern.compile("{tag:/V.*/}=pred >/nmod:agent/=reln {tag:/NNP?S?/}=subj >nsubjpass {tag:/NNP?S?/}=obj ");
45+
public static SemgrexPattern AGENT_PATTERN = SemgrexPattern.compile("{tag:/V.*/}=pred >/obl:agent/=reln {tag:/NNP?S?/}=subj >/nsubj:pass/ {tag:/NNP?S?/}=obj ");
4646

4747
/* A cat sitting in a chair. */
48-
public static SemgrexPattern ACL_PATTERN = SemgrexPattern.compile("{}=subj >acl ({tag:/V.*/}=pred >/(iobj|dobj|nmod:.*)/=objreln {tag:/NNP?S?/}=obj)");
48+
public static SemgrexPattern ACL_PATTERN = SemgrexPattern.compile("{}=subj >acl ({tag:/V.*/}=pred >/(iobj|obj|nmod:.*|obl:.*)/=objreln {tag:/NNP?S?/}=obj)");
4949

5050
//TODO: do something special with nmod:by
5151

src/edu/stanford/nlp/trees/UniversalEnglishGrammaticalStructure.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,17 @@ private static void createMultiWordExpression(SemanticGraph sg, IndexedWord gov,
17551755
sg.addEdge(mweHead, word, MULTI_WORD_EXPRESSION, Double.NEGATIVE_INFINITY, false);
17561756
}
17571757
}
1758+
1759+
// attach any dependents (e.g., case makers) to the governor of the MWE
1760+
for (IndexedWord word : words) {
1761+
for (SemanticGraphEdge edge : new ArrayList<>(sg.getOutEdgesSorted(word))) {
1762+
if (edge.getRelation() != MULTI_WORD_EXPRESSION) {
1763+
sg.removeEdge(edge);
1764+
sg.addEdge(gov, edge.getDependent(), edge.getRelation(), edge.getWeight(), edge.isExtra());
1765+
}
1766+
}
1767+
}
1768+
17581769
}
17591770

17601771

0 commit comments

Comments
 (0)