Skip to content

Commit 1915bbe

Browse files
committed
Fixes Yoda speak dependencies
actually, there's only one in PTB - Also excluded will be investments ...
1 parent 8880cc6 commit 1915bbe

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ public Tree transformTree(Tree t) {
164164
if (VERBOSE) {
165165
debugLine("After rearrangeNowThat: ", t);
166166
}
167-
167+
t = mergeYodaVerbs(t);
168+
if (VERBOSE) {
169+
debugLine("After mergeYodaVerbs: ", t);
170+
}
168171
return t;
169172
}
170173

@@ -182,6 +185,19 @@ private static Tree rearrangeNowThat(Tree t) {
182185
}
183186

184187

188+
private static final TregexPattern mergeYodaVerbsTregex =
189+
TregexPattern.compile("VP=home < VBN=vbn $+ (VP=willbe <... {(__=will < will|have|has) ; (VP < (__=be << be|been))})");
190+
191+
private static final TsurgeonPattern mergeYodaVerbsTsurgeon =
192+
Tsurgeon.parseOperation("[createSubtree VP vbn] [move will >-1 home] [move be >-1 home] [prune willbe]");
193+
194+
private static Tree mergeYodaVerbs(Tree t) {
195+
if (t == null) {
196+
return t;
197+
}
198+
return Tsurgeon.processPattern(mergeYodaVerbsTregex, mergeYodaVerbsTsurgeon, t);
199+
}
200+
185201
private static final TregexPattern changeSbarToPPTregex =
186202
TregexPattern.compile("NP < (NP $++ (SBAR=sbar < (IN < /^(?i:after|before|until|since|during)$/ $++ S)))");
187203

test/src/edu/stanford/nlp/trees/EnglishGrammaticalStructureTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public void testBasicRelations() {
285285
"aux(excluded-7, will-5)\n" +
286286
"auxpass(excluded-7, be-6)\n" + "root(ROOT-0, excluded-7)\n",
287287
"advmod(excluded-2, Also-1)\n" + "root(ROOT-0, excluded-2)\n" +
288-
"aux(be-4, will-3)\n" + // should really be aux(excluded-2, will-3) but impossible at present without reconstructing topicalized VP semantic head
288+
"aux(excluded-2, will-3)\n" +
289289
"auxpass(excluded-2, be-4)\n" +
290290
"nsubjpass(excluded-2, investments-5)\n" +
291291
"prep(investments-5, in-6)\n" +

0 commit comments

Comments
 (0)