Skip to content

Commit 20062f4

Browse files
committed
Fixes Yoda speak dependencies
actually, there's only one in PTB - Also excluded will be investments ...
1 parent 247e95e commit 20062f4

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

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

+17-1
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

+1-1
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" +

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ public static Collection<Object[]> testCases() {
580580
"( (SINV (ADVP (RB Also)) (VP (VBN excluded)) (VP (MD will) (VP (VB be))) (NP (NP (NNS investments)) (PP (IN in) (NP (NNP South) (NNP Africa)))) (. .)))",
581581
"advmod(excluded-2, Also-1)\n" +
582582
"root(ROOT-0, excluded-2)\n" +
583-
"aux(be-4, will-3)\n" + // should really be aux(excluded-2, will-3) but impossible at present without reconstructing topicalized VP semantic head
583+
"aux(excluded-2, will-3)\n" +
584584
"aux:pass(excluded-2, be-4)\n" +
585585
"nsubj:pass(excluded-2, investments-5)\n" +
586586
"case(Africa-8, in-6)\n" +

0 commit comments

Comments
 (0)