Package edu.stanford.nlp.trees

Examples of edu.stanford.nlp.trees.PennTreeReader


     * @see edu.jhu.hltcoe.sp.data.depparse.AgigaSentence#getStanfordContituencyTree()
     */
    public Tree getStanfordContituencyTree() {
        TreeFactory tf = new LabeledScoredTreeFactory();
        StringReader r = new StringReader(getParseText());
        TreeReader tr = new PennTreeReader(r, tf);
        try {
            return tr.readTree();
        } catch (IOException e) {
            throw new RuntimeException("Error: IOException should not be thrown by StringReader");
        }
    }
View Full Code Here


  /**
   * Read a tree from a PTB-style serialized form in the given string.
   */
  private Tree readTree(String treeRep) {
    try {
      return new PennTreeReader(new StringReader(treeRep), tf).readTree();
    } catch (IOException e) { return null; }
  }
View Full Code Here

    List<CoreMap> sentences = new ArrayList<CoreMap>();
    while((line = reader.readLine()) != null){
      CoreMap sentence = new Annotation("");

      // first line is the parse tree. construct it with CoreLabels in Tree nodes
      Tree tree = new PennTreeReader(new StringReader(line), new LabeledScoredTreeFactory(CoreLabel.factory())).readTree();
      sentence.set(TreeCoreAnnotations.TreeAnnotation.class, tree);

      // read the dependency graphs
      IntermediateSemanticGraph intermCollapsedDeps = loadDependencyGraph(reader);
      IntermediateSemanticGraph intermUncollapsedDeps = loadDependencyGraph(reader);
View Full Code Here

      // Pass 2: Guess what the object could be
      if (Tree.class.isAssignableFrom(clazz)) {
        // (case: reading a tree)
        try {
          return (E) new PennTreeReader(new StringReader(value), new LabeledScoredTreeFactory(CoreLabel.factory())).readTree();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      } else if (Collection.class.isAssignableFrom(clazz)) {
        // (case: reading a collection)
View Full Code Here

  // TODO
  private static final long serialVersionUID = 8L;

  public TreeReader newTreeReader(Reader in) {
    return new PennTreeReader(in, new LabeledScoredTreeFactory(),
                              new SpanishTreeNormalizer(false, false, false),
                              new PennTreebankTokenizer(in));
  }
View Full Code Here

public class HebrewTreeReaderFactory implements TreeReaderFactory, Serializable {

  private static final long serialVersionUID = 818065349424602548L;

  public TreeReader newTreeReader(Reader in) {
    return new PennTreeReader(in, new LabeledScoredTreeFactory(), new HebrewTreeNormalizer(),new PennTreebankTokenizer(in));
  }
View Full Code Here

  }

  public TreeReader newTreeReader(Reader in) {
    TreeReader tr = null;
    if(noNormalization) {
      tr = new PennTreeReader(in, new LabeledScoredTreeFactory(), new TreeNormalizer(), new ArabicTreebankTokenizer(in));
    } else
      tr = new PennTreeReader(in, new LabeledScoredTreeFactory(), new ArabicTreeNormalizer(retainNPTmp,retainPRD,changeNoLabels, retainNPSbj, retainPPClr), new ArabicTreebankTokenizer(in));

    if (filterX)
      tr = new FilteringTreeReader(tr, new XFilter());

    return tr;
View Full Code Here

  public TreeReader newTreeReader(Reader in) {
    final NegraPennTreeNormalizer tn = new NegraPennTreeNormalizer(tlp, nodeCleanup);
    if (treeNormalizerInsertNPinPP)
      tn.setInsertNPinPP(true);

    return new PennTreeReader(in, new LabeledScoredTreeFactory(), tn, new NegraPennTokenizer(in));
  }
View Full Code Here

    // String ptbTreeString1 = "(ROOT (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN test))) (. .)))";
    String ptbTreeString = "(ROOT (S (NP (NNP Interactive_Tregex)) (VP (VBZ works)) (PP (IN for) (PRP me)) (. !))))";
    if (args.length > 0) {
      ptbTreeString = args[0];
    }
    Tree tree = (new PennTreeReader(new StringReader(ptbTreeString), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree();
    tjp.setTree(tree);
    tjp.setBackground(Color.white);
    JFrame frame = new JFrame();
    frame.getContentPane().add(tjp, BorderLayout.CENTER);
    frame.addWindowListener(new WindowAdapter() {
View Full Code Here

  public void testPositions() {
    try {
      // System.err.println();
      // System.err.println("One.");
      // check a tree loaded from a reader, using StringLabelFactory
      Tree tree = (new PennTreeReader(new StringReader("(S (NP (NNP Mary)) (VP (VBD had) (NP (DT a) (JJ little) (NN lamb))) (. .))"), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree();
      //System.out.println(tree.pennString());
      checkTree(tree);

      // System.err.println("Two.");
      // check a tree created using Tree.valueOf()
      tree = Tree.valueOf("(S (NP (NNP Mary)) (VP (VBD had) (NP (DT a) (JJ little) (NN lamb))) (. .))");
      //System.out.println(tree.pennString());
      checkTree(tree);

      // System.err.println("Three.");
      // check a tree loaded from a reader, using CoreLabelFactory
      tree = (new PennTreeReader(new StringReader("(S (NP (NNP Mary)) (VP (VBD had) (NP (DT a) (JJ little) (NN lamb))) (. .))"), new LabeledScoredTreeFactory(CoreLabel.factory()))).readTree();
      //System.out.println(tree.pennString());
      checkTree(tree);

      // System.err.println("Four.");
      // check a tree generated by the parser
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.trees.PennTreeReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.