Package com.clearnlp.dependency

Examples of com.clearnlp.dependency.DEPTree


    String form, lemma, pos, label;
    DEPFeat feats;
    String[] tmp;
    DEPNode node;
   
    DEPTree tree = new DEPTree();
    for (i=0; i<size; i++tree.add(new DEPNode());
   
    for (i=0; i<size; i++)
    {
      tmp   = lines.get(i);
      id    = Integer.parseInt(tmp[i_id]);
      form  = tmp[i_form];
      lemma = tmp[i_lemma];
      pos   = tmp[i_pos];
      feats = new DEPFeat(tmp[i_feats]);
     
      node = tree.get(id);
      node.init(id, form, lemma, pos, feats);
         
      if (i_xheads >= 0 && !tmp[i_xheads].equals(AbstractColumnReader.BLANK_COLUMN))
      {
        for (String head : tmp[i_xheads].split(DEPLib.DELIM_HEADS))
        {
          tmp    = head.split(DEPLib.DELIM_HEADS_KEY);
          headId = Integer.parseInt(tmp[0]);
          label  = tmp[1];
         
          node.addXHead(tree.get(headId), label);
        }
      }
    }
   
    return tree;
View Full Code Here


  }
 
  void generation(String[] args)
  {
    Pattern ignore = Pattern.compile("AM-MOD|AM-ADV|C-.+|R-.+");
    DEPTree tree = new DEPTree();
   
    tree.add(new DEPNode(1, "Tell"   , "tell" , "VB" , new DEPFeat()));
    tree.add(new DEPNode(2, "me"     , "me"   , "PRP", new DEPFeat()));
    tree.add(new DEPNode(3, "about"  , "about", "IN" , new DEPFeat()));
    tree.add(new DEPNode(4, "berries", "berry", "NNS", new DEPFeat()));

    tree.get(1).setHead(tree.get(0), DEPLibEn.DEP_ROOT);
    tree.get(2).setHead(tree.get(1), DEPLibEn.DEP_DOBJ);
    tree.get(3).setHead(tree.get(1), DEPLibEn.DEP_PREP);
    tree.get(4).setHead(tree.get(3), DEPLibEn.DEP_POBJ);
   
    tree.setDependents();
    tree.initSHeads();
   
    tree.get(1).addFeat(DEPLib.FEAT_PB, "tell.01");
    tree.get(2).addSHead(tree.get(1), "A2");
    tree.get(3).addSHead(tree.get(1), "A1");
   
    SRLTree sTree = tree.getSRLTree(1);
    System.out.println(sTree.getRichKeyEn(ignore, "."));
  }
View Full Code Here

  }
 
  /** Generates a question from a declarative sentence. */
  public DEPTree generateQuestionFromDeclarative(DEPNode root, boolean convertUnI)
  {
    DEPTree tree = new DEPTree();
   
    for (DEPNode node : root.getSubNodeSortedList())
      tree.add(node);
   
    return generateQuestionFromDeclarative(tree, convertUnI);
  }
View Full Code Here

 
  /** Called by {@link LGAsk#generateQuestionFromAsk(DEPTree, String)}. */
  public DEPTree generateQuestion(DEPNode verb, List<DEPNode> prevNodes)
  {
    Set<DEPNode> added = new HashSet<DEPNode>();
    DEPTree tree = new DEPTree();
    DEPNode rel, aux;
   
    if (prevNodes != null)
    {
      tree.addAll(prevNodes);
      added.addAll(prevNodes);
    }
   
    verb.setHead(tree.get(0), DEPLibEn.DEP_ROOT);
    rel = setRelativizer(tree, verb, added);
   
    aux = setAuxiliary(tree, verb, added, rel);
    setRest(tree, verb, added);
    resetDEPTree(tree, verb);
View Full Code Here

  void extractVerbPP(String[] args)
  {
    SRLReader reader = new SRLReader(0, 1, 2, 3, 4, 5, 6, 8);
    reader.open(UTInput.createBufferedFileReader(args[0]));
    Prob2DMap map = new Prob2DMap();
    DEPTree tree;
   
    while ((tree = reader.next()) != null)
      extractVerbPPAux(tree, map);
   
    PrintStream fout = UTOutput.createPrintBufferedFileStream(args[1]);
View Full Code Here

    SRLReader reader = new SRLReader(0, 1, 2, 3, 4, 5, 6, 7);
    reader.open(UTInput.createBufferedFileReader(args[0]));
    PrintStream fout = UTOutput.createPrintBufferedFileStream(args[1]);
    Pattern p = UTRegex.getORPatternExact(DEPLibEn.DEP_COMPLM, DEPLibEn.DEP_MARK);
    DEPNode root, head;
    DEPTree tree;
   
    while ((tree = reader.next()) != null)
    {
      tree.setDependents();
      root = tree.getFirstRoot();
      head = root.getDependents().get(0).getNode();
     
      tree = new DEPTree();
      head.removeDependentsByLabels(p);
     
      for (DEPNode node : head.getSubNodeSortedList())
      {
        tree.add(node);
        if (node.isDependentOf(root))
          node.setHead(tree.get(0), DEPLibEn.DEP_ROOT);
      }
     
      tree.resetIDs();
      fout.println(tree.toStringSRL()+"\n");
    }
   
    fout.close();
    reader.close()
  }
View Full Code Here

    Set<String> keys = new TreeSet<String>();
    Prob2DMap mVBD = new Prob2DMap();
    Prob2DMap mVBN = new Prob2DMap();
    String form, base, past, part;
    int i, size, cutoff = 1;
    DEPTree tree;
    DEPNode node;
   
    while ((tree = fin.next()) != null)
    {
      size = tree.size();
     
      for (i=1; i<size; i++)
      {
        node = tree.get(i);
        base = node.lemma;
        form = node.form.toLowerCase();
        past = LGVerbEn.getPastRegularForm(base);
       
        if (node.isPos(CTLibEn.POS_VBD))
View Full Code Here

    fin.open(UTInput.createBufferedFileReader(args[0]));
    PrintStream fold = UTOutput.createPrintBufferedFileStream(args[0]+".o");
    PrintStream fnew = UTOutput.createPrintBufferedFileStream(args[0]+".n");
  //  ObjectInputStream oin = new ObjectInputStream(new BufferedInputStream(new FileInputStream(args[1])));
  //  PBFrameset p = (PBFrameset)oin.readObject();
    DEPTree tree;
   
    while ((tree = fin.next()) != null)
    {
      fold.println(tree.toStringSRL()+"\n");
      DEPLibEn.postLabel(tree);
      fnew.println(tree.toStringSRL()+"\n");
    }
  }
View Full Code Here

    AbstractC2DConverter converter = new KaistC2DConverter(new HeadRuleMap(UTInput.createBufferedFileReader(args[0])));
    String[] inputFiles = UTFile.getSortedFileList(args[1], "ptb");
    String outputFile;
    PrintStream fout;
    CTReader reader;
    DEPTree dTree;
    CTTree cTree;
   
    for (String inputFile : inputFiles)
    {
      outputFile = UTFile.replaceExtension(inputFile, "dep");
      reader = new CTReader(UTInput.createBufferedFileReader(inputFile));
      fout = UTOutput.createPrintBufferedFileStream(outputFile);
      System.out.println(outputFile);
     
      while ((cTree = reader.nextTree()) != null)
      {
        dTree = converter.toDEPTree(cTree);
        fout.println(dTree.toStringDEP()+"\n");
      }
     
      reader.close();
      fout.close();
    }
View Full Code Here

  {
  //  DEPReader reader = new DEPReader(0, 1, 2, 3, 5, 6, 7);
    DEPReader reader = new DEPReader(0, 1, 2, 4, 6, 8, 10);
    reader.open(UTInput.createBufferedFileReader(inputFile));
    int i, size, left = 0, right = 0, l, r, prevId, depId;
    DEPTree tree;
    DEPNode node;
   
    while ((tree = reader.next()) != null)
    {
      tree.setDependents();
      size = tree.size();
     
      for (i=1; i<size; i++)
      {
        node = tree.get(i);
        prevId = -1;
        l = r = 0;
       
        for (DEPArc arc : node.getDependents())
        {
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.