Package org.fnlp.nlp.parser.dep

Examples of org.fnlp.nlp.parser.dep.DependencyTree


  @Override
  public void addThruPipe(Instance inst) throws Exception {
    String data = (String)inst.getData();
//    System.out.println(data);
    DependencyTree t = factory.parse2T(data);
   

    inst.setData(t);
  }
View Full Code Here


   */
  public DependencyTree parse2T(String[] words, String[] pos) {
    if(parser==null)
      return null;
    if(treeCache!=null){
      DependencyTree tree = treeCache.get(words,pos);
      if(tree!=null)
        return tree;
    }
   
    if(words==null||pos==null||words.length==0||pos.length==0||words.length!=pos.length)
View Full Code Here

   */
  private static void test(String word) throws Exception {   
    POSTagger tag = new POSTagger("../models/seg.m","../models/pos.m");
    String[][] s = tag.tag2Array(word);
    try {
      DependencyTree tree = parser.parse2T(s[0],s[1]);
      System.out.println(tree.toString());
      String stree = parser.parse2String(s[0],s[1],true);
      System.out.println(stree);
    } catch (Exception e) {     
      e.printStackTrace();
    }
View Full Code Here

    return t;
  }

  private static void to2HeadsArray(DependencyTree dt, Target t) {
    for(int i = 0; i < dt.leftChilds.size(); i++)  {
      DependencyTree ch = dt.leftChilds.get(i);
      t.setHeads(ch.id, dt.id);
      t.setDepClass(ch.id, ch.getDepClass());
      to2HeadsArray(ch,t);
    }
    t.words[dt.id] = dt.word;
    t.pos[dt.id] = dt.pos;
    for(int i = 0; i < dt.rightChilds.size(); i++)  {
      DependencyTree ch = dt.rightChilds.get(i);
      t.setHeads(ch.id,dt.id);
      t.setDepClass(ch.id,ch.getDepClass());
      to2HeadsArray(ch,t);
    }
  }
View Full Code Here

      return false;
  }

  public DependencyTree toTree() {
    ArrayList<DependencyTree> nodes = new ArrayList<DependencyTree>();
    DependencyTree root = null;
    for(int j=0;j<words.length;j++){
      DependencyTree node = new DependencyTree(j, words[j],tags[j], relations[j]);
      nodes.add(node);
    }
    for(int j=0;j<words.length;j++){
      int head = heads[j];
      if(head==-1)
View Full Code Here

      return false;
  }

  public DependencyTree toTree() {
    ArrayList<DependencyTree> nodes = new ArrayList<DependencyTree>();
    DependencyTree root = null;
    for(int j=0;j<words.length;j++){
      DependencyTree node = new DependencyTree(j, owords[j],otags[j], relations[j]);
      nodes.add(node);
    }
    for(int j=0;j<words.length;j++){
      int head = heads[j];
      if(head==-1)
View Full Code Here

TOP

Related Classes of org.fnlp.nlp.parser.dep.DependencyTree

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.