Package com.clearnlp.dependency

Examples of com.clearnlp.dependency.DEPTree


  }
 
  void projectivize(String inputFile, String outputFile)
  {
    DEPReader reader = new DEPReader(0, 1, 2, 4, 6, 8, 10);
    DEPTree tree;
   
    reader.open(UTInput.createBufferedFileReader(inputFile));
    PrintStream fold = UTOutput.createPrintBufferedFileStream(outputFile+".old");
    PrintStream fnew = UTOutput.createPrintBufferedFileStream(outputFile+".new");
    int i;
   
    for (i=0; (tree = reader.next()) != null; i++)
    {
      fold.println(tree.toStringCoNLL()+"\n");
      tree.projectivize();
      fnew.println(tree.toStringCoNLL()+"\n");
     
      if (i%1000 == 0System.out.print(".");
    System.out.println();
   
    reader.close();
View Full Code Here


    reader.open(UTInput.createBufferedFileReader(inputFile));
    PrintStream fout = UTOutput.createPrintBufferedFileStream(outputFile);
    Prob2DMap map = new Prob2DMap();
    DEPNode node, head;
    String deprel, label, ftags;
    DEPTree tree;
    int i, size;
   
    while ((tree = reader.next()) != null)
    {
      size = tree.size();
     
      for (i=1; i<size; i++)
      {
        node   = tree.get(i);
        head   = node.getHead();
        deprel = node.getLabel();
        if ((ftags = node.getFeat(DEPLib.FEAT_SEM)) != null)
          deprel = ftags;
       
View Full Code Here

 
  public void countSemanticDependents(String[] args)
  {
    SRLReader reader = new SRLReader(0, 1, 2, 3, 4, 5, 6, 8);
    reader.open(UTInput.createBufferedFileReader(args[0]));
    DEPTree tree;
    DEPNode node, dHead, sHead;
    int i;
   
    while ((tree = reader.next()) != null)
    {
      tree.setDependents();
     
      for (i=1; i<tree.size(); i++)
      {
        node  = tree.get(i);
        dHead = node.getHead();
       
        for (DEPArc sArc : node.getSHeads())
        {
          sHead = sArc.getNode();
        //  sHead = sArc.getNode().getHead();
         
          if (sHead != dHead && sHead != dHead.getHead() && node.isDescendentOf(sHead))
          {
            System.out.println(node.id+" "+sArc.getNode().id+" "+tree.toStringSRL());
            try {System.in.read();} catch (IOException e) {e.printStackTrace();}
          }
        }
      }
    }
View Full Code Here

  }
 
  private List<Pair<String,String>> getLongAnswers(List<DEPTree> rTrees, List<ArgInfo> rArgs, String conjunction, String delim)
  {
    List<Pair<String,String>> answers = new ArrayList<Pair<String,String>>();
    DEPTree rTree;
    ArgInfo rArg;
    int i;
   
    for (i=rTrees.size()-1; i>=0; i--)
    {
      rTree = rTrees.get(i);
      rArg  = rArgs.get(i);
      answers.add(getAnswerString(rTree.get(rArg.getPredicateId()), delim));
    }

    return answers;
  }
View Full Code Here

{
  public DEPErrors(String mergeFile)
  {
    DEPReader gReader = new DEPReader(0, 1, 2, 4, 6, 7, 9);
    DEPReader sReader = new DEPReader(0, 1, 3, 5, 6, 8, 10);
    DEPTree gTree, sTree;
   
    gReader.open(UTInput.createBufferedFileReader(mergeFile));
    sReader.open(UTInput.createBufferedFileReader(mergeFile));
   
    String[] errors = {
        "sHead is a dependent       of gHead",
        "sHead is a grand-dependent of gHead",
        "gHead is a sibling         of sHead",
        "sHead is a descendent      of gHead",
        "gHead is a sibling         of cHead",
        "gHead is a dependent       of cNode",
        "gHead is a grand-dependent of sHead"
    };
   
    int[] counts = new int[errors.length+1];   
   
    while ((gTree = gReader.next()) != null)
    {
      sTree = sReader.next();
      gTree.setDependents();
      sTree.setDependents();
      checkErrors(gTree, sTree, counts);
    }
   
    int i, size = counts.length, total = counts[0], count, sum = 0;
View Full Code Here

  @Override
  protected void postLabel(SRLState state)
  {
    if (isDecode())
    {
      DEPTree tree = state.getTree();
      List<List<DEPArc>> argLists = DEPLibEn.postLabel(tree);
      postLabelReferent(tree, argLists);
    }
  }
View Full Code Here

      }
      catch (Exception e) {e.printStackTrace();}
     
      PrintStream fout = UTOutput.createPrintBufferedFileStream(UTFile.replaceExtension(inputPath, outputExt));
      CTReader reader = new CTReader(UTInput.createBufferedFileReader(inputPath));
      CTTree cTree; DEPTree dTree; int n;
      List<PBInstance> instances = null;
     
      for (n=0; (cTree = reader.nextTree()) != null; n++)
      {
        if (language.equals(AbstractReader.LANG_EN))
View Full Code Here

  public DEPTree getDEPTreeWithoutEdited(CTTree cTree, DEPTree dTree)
  {
    IntOpenHashSet set = new IntOpenHashSet();
    addEditedTokensAux(cTree.getRoot(), set);
    int i, j, size = dTree.size();
    DEPTree tree = new DEPTree();
    DEPNode node;
   
    for (i=1,j=1; i<size; i++)
    {
      if (!set.contains(i))
      {
        node = dTree.get(i);
        node.id = j++;
        removeEditedHeads(node.getXHeads(), set);
        removeEditedHeads(node.getSHeads(), set);
        tree.add(node);
      }
    }
   
    return (tree.size() == 1) ? null : tree;
  }
View Full Code Here

    }
  }
 
  public DEPTree getNullTree()
  {
    DEPTree tree = new DEPTree();
   
    DEPNode dummy = new DEPNode(1, "NULL", "NULL", "NULL", new DEPFeat());
    dummy.setHead(tree.get(0), "NULL");
   
    tree.add(dummy);
    tree.initXHeads();
    tree.initSHeads();
   
    return tree;
  }
View Full Code Here

  private Set<String> getLowerSimplifiedForms(JointReader reader, JointFtrXml xml, String[] trainFiles, int devId)
  {
    Set<String> set = new HashSet<String>();
    int i, j, len, size = trainFiles.length;
    Prob1DMap map = new Prob1DMap();
    DEPTree tree;
   
    LOG.info("Collecting word-forms:\n");
   
    for (i=0; i<size; i++)
    {
      if (devId == icontinue;
     
      reader.open(UTInput.createBufferedFileReader(trainFiles[i]));
      set.clear();
     
      while ((tree = reader.next()) != null)
      {
        NLPProcess.simplifyForms(tree);
        len = tree.size();
       
        for (j=1; j<len; j++)
          set.add(tree.get(j).lowerSimplifiedForm);
      }
     
      reader.close();
      map.addAll(set);
      LOG.debug(".");
View Full Code Here

TOP

Related Classes of com.clearnlp.dependency.DEPTree

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.