6
6
import edu .stanford .nlp .semgraph .SemanticGraph ;
7
7
import edu .stanford .nlp .semgraph .SemanticGraphFactory ;
8
8
import edu .stanford .nlp .trees .*;
9
+ import edu .stanford .nlp .trees .treebank .EnglishPTBTreebankCorrector ;
9
10
import edu .stanford .nlp .util .Pair ;
10
11
import edu .stanford .nlp .util .PropertiesUtils ;
11
12
import edu .stanford .nlp .util .StringUtils ;
@@ -229,6 +230,7 @@ private static void addSpaceAfter(SemanticGraph sg, String text, int graphIdx) {
229
230
* {@code -textFile}: A file with text to be used as a guide for SpaceAfter (optional)<br>
230
231
* {@code -outputRepresentation}: "basic" (default), "enhanced", or "enhanced++"<br>
231
232
* {@code -combineMWTs}: "False" (default), "True" marks things like it's as MWT
233
+ * {@code -correctPTB}: "False" (default), "True" runs the PTB Corrector over the trees
232
234
*/
233
235
public static void main (String [] args ) {
234
236
Properties props = StringUtils .argsToProperties (args );
@@ -239,6 +241,7 @@ public static void main(String[] args) {
239
241
boolean addFeatures = PropertiesUtils .getBool (props , "addFeatures" , false );
240
242
boolean combineMWTs = PropertiesUtils .getBool (props , "combineMWTs" , false );
241
243
boolean replaceLemmata = PropertiesUtils .getBool (props , "replaceLemmata" , false );
244
+ boolean correctPTB = PropertiesUtils .getBool (props , "correctPTB" , false );
242
245
243
246
Iterator <Pair <SemanticGraph , SemanticGraph >> sgIterator ; // = null;
244
247
@@ -258,7 +261,7 @@ public static void main(String[] args) {
258
261
System .err .println ("No input file specified!" );
259
262
System .err .println ();
260
263
System .err .printf ("Usage: java %s [-treeFile trees.tree | -conlluFile deptrees.conllu]" +
261
- " [-addFeatures] [-replaceLemmata] [-textFile trees.txt] [-outputRepresentation basic|enhanced|enhanced++ (default: basic)]%n" ,
264
+ " [-addFeatures] [-replaceLemmata] [-correctPTB] [- textFile trees.txt] [-outputRepresentation basic|enhanced|enhanced++ (default: basic)]%n" ,
262
265
UniversalDependenciesConverter .class .getCanonicalName ());
263
266
return ;
264
267
}
@@ -271,6 +274,7 @@ public static void main(String[] args) {
271
274
272
275
UniversalDependenciesFeatureAnnotator featureAnnotator = (addFeatures ) ? new UniversalDependenciesFeatureAnnotator () : null ;
273
276
EnglishMWTCombiner mwtCombiner = (combineMWTs ) ? new EnglishMWTCombiner () : null ;
277
+ EnglishPTBTreebankCorrector ptbCorrector = (correctPTB ) ? new EnglishPTBTreebankCorrector () : null ;
274
278
275
279
CoNLLUDocumentWriter writer = new CoNLLUDocumentWriter ();
276
280
@@ -282,6 +286,9 @@ public static void main(String[] args) {
282
286
if (treeFileName != null ) {
283
287
//add UPOS tags
284
288
Tree tree = ((TreeToSemanticGraphIterator ) sgIterator ).getCurrentTree ();
289
+ if (ptbCorrector != null ) {
290
+ tree = ptbCorrector .transformTree (tree );
291
+ }
285
292
Tree uposTree = UniversalPOSMapper .mapTree (tree );
286
293
List <Label > uposLabels = uposTree .preTerminalYield ();
287
294
for (IndexedWord token : sg .vertexListSorted ()) {
0 commit comments