Ejemplo n.º 1
0
  public static void main(String[] args) {

    QPTreeTransformer transformer = new QPTreeTransformer();
    Treebank tb = new MemoryTreebank();
    Properties props = StringUtils.argsToProperties(args);
    String treeFileName = props.getProperty("treeFile");

    if (treeFileName != null) {
      try {
        TreeReader tr =
            new PennTreeReader(
                new BufferedReader(new InputStreamReader(new FileInputStream(treeFileName))),
                new LabeledScoredTreeFactory());
        Tree t;
        while ((t = tr.readTree()) != null) {
          tb.add(t);
        }
      } catch (IOException e) {
        throw new RuntimeException("File problem: " + e);
      }
    }

    for (Tree t : tb) {
      System.out.println("Original tree");
      t.pennPrint();
      System.out.println();
      System.out.println("Tree transformed");
      Tree tree = transformer.transformTree(t);
      tree.pennPrint();
      System.out.println();
      System.out.println("----------------------------");
    }
  }
Ejemplo n.º 2
0
 /**
  * Return a MemoryTreebank where each Tree in the current treebank has been transformed using the
  * TreeTransformer. This Treebank is unchanged (assuming that the TreeTransformer correctly
  * doesn't change input Trees).
  *
  * @param treeTrans The TreeTransformer to use
  */
 @Override
 public Treebank transform(TreeTransformer treeTrans) {
   Treebank mtb = new MemoryTreebank(size(), treeReaderFactory());
   for (Tree t : this) {
     mtb.add(treeTrans.transformTree(t));
   }
   return mtb;
 }