Package edu.stanford.nlp.trees

Examples of edu.stanford.nlp.trees.TreeFactory


   
    /* (non-Javadoc)
     * @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) {
View Full Code Here


  }

  private static void resolveDummyTags(File treeFile,
                                       TwoDimensionalCounter<String, String> unigramTagger,
                                       boolean retainNER, TreeNormalizer tn) {
    TreeFactory tf = new LabeledScoredTreeFactory();
    MultiWordTreeExpander expander = new MultiWordTreeExpander();

    try {
      BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(treeFile), "UTF-8"));
      TreeReaderFactory trf = new SpanishTreeReaderFactory();
View Full Code Here

   * Construct a fall through tree in case we can't parse this sentence
   * @param words
   * @return a tree with X for all the internal nodes.  preterminals have the right tag if the words are tagged
   */
  public static Tree xTree(List<? extends HasWord> words) {
    TreeFactory lstf = new LabeledScoredTreeFactory();
    List<Tree> lst2 = new ArrayList<Tree>();
    for (HasWord obj : words) {
      String s = obj.word();
      Tree t = lstf.newLeaf(s);
      String tag = "XX";
      if (obj instanceof HasTag) {
        if (((HasTag) obj).tag() != null) {
          tag = ((HasTag) obj).tag();
        }
      }
      Tree t2 = lstf.newTreeNode(tag, Collections.singletonList(t));
      lst2.add(t2);
    }
    return lstf.newTreeNode("X", lst2);
  }
View Full Code Here

      System.exit(-1);
    }

    PrintWriter pwo = tlpp.pw();
    String startSymbol = tlpp.treebankLanguagePack().startSymbol();
    TreeFactory tf = new LabeledScoredTreeFactory();
    int nTrees = 0;
    for(Tree t : tb) {
      if(removeBracket) {
        if(t.value().equals(startSymbol)) {
          t = t.firstChild();
        }
       
      } else if( ! t.value().equals(startSymbol)) { //Add a bracket if it isn't already there
        t = tf.newTreeNode(startSymbol, Collections.singletonList(t));
      }
      pwo.println(t.toString());
      nTrees++;
    }     
    pwo.close();
View Full Code Here

  private final HeadFinder hf;
  private final TrainOptions trainOptions;

  @Override
  public Tree transformTree(Tree t) {
    TreeFactory tf = t.treeFactory();
    return transformTreeHelper(t, t, tf);
  }
View Full Code Here

   * major yuk here. Reproduces the emptyType and traceTo from the
   * leaf out of which the treeFactory is vended.
   */
  @Override
  public TreeFactory treeFactory() {
    return new TreeFactory() {
      TreeFactory lstf = new LabeledScoredTreeFactory();

      public Tree newLeaf(Label l) {
        return new EmptyTreeLeaf<EmptyType>(l, emptyType(), traceTo());
      }
View Full Code Here

TOP

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

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.