Skip to content

Commit 3a33fef

Browse files
committed
Remove the QP in a structure such as '(NP (QP About a) day)' so that the resulting dependencies both connect to day instead of from about -> a, changing the UD nummod to a det
1 parent 31fcbf2 commit 3a33fef

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ public Tree transformTree(Tree t) {
100100
private static final TsurgeonPattern splitMoneyTsurgeon =
101101
Tsurgeon.parseOperation("createSubtree QP left right");
102102

103+
// Remove QP in a structure such as
104+
// (NP (QP nearly_RB all_DT) stuff_NN)
105+
// so that the converter can attach both `nearly` and `all` to `stuff`
106+
// not using a nummod, either, which is kind of annoying
107+
private static final TregexPattern flattenAdvmodTregex =
108+
TregexPattern.compile("NP < (QP=remove <1 RB <2 (DT !$+ __) $++ /^N/)");
109+
110+
private static final TsurgeonPattern flattenAdvmodTsurgeon =
111+
Tsurgeon.parseOperation("excise remove remove");
112+
103113
/**
104114
* Transforms t if it contains one of the following QP structure:
105115
* <ul>
@@ -121,6 +131,7 @@ public Tree QPtransform(Tree t) {
121131
}
122132
t = Tsurgeon.processPattern(splitCCTregex, splitCCTsurgeon, t);
123133
t = Tsurgeon.processPattern(splitMoneyTregex, splitMoneyTsurgeon, t);
134+
t = Tsurgeon.processPattern(flattenAdvmodTregex, flattenAdvmodTsurgeon, t);
124135
return t;
125136
}
126137

0 commit comments

Comments
 (0)