Package com.clearnlp.dependency

Examples of com.clearnlp.dependency.DEPTree


  }
 
  protected double decode(JointReader reader, AbstractStatisticalComponent<?> component, String[] devFiles, String ext, boolean generate) throws Exception
  {
    PrintStream fout = null;
    DEPTree tree;
   
    for (String devFile : devFiles)
    {
      if (generate) fout = UTOutput.createPrintBufferedFileStream(devFile+ext);
      reader.open(UTInput.createBufferedFileReader(devFile));
View Full Code Here


 
  protected Object[] getLexica(JointReader reader, AbstractStatisticalComponent<?> collector, JointFtrXml[] xmls, String[] trainFiles, int devId)
  {
    if (collector == null) return null;
    int i, size = trainFiles.length;
    DEPTree tree;
   
    LOG.info("Collecting lexica:\n");
   
    for (i=0; i<size; i++)
    {
View Full Code Here

      j_component = component;
    }
   
    public void run()
    {
      DEPTree tree;
     
      while ((tree = j_reader.next()) != null)
        j_component.process(tree);
     
      j_reader.close();
View Full Code Here

    return new EnglishRolesetClassifier(in);
  }

  static public DEPTree toDEPTree(List<String> tokens)
  {
    DEPTree tree = new DEPTree();
    int i, size = tokens.size();
   
    for (i=0; i<size; i++)
      tree.add(new DEPNode(i+1, tokens.get(i)));
   
    return tree;
  }
View Full Code Here

    }
    else if (isEvaluate(flag))
    {
      if (e_eval == null) e_eval = new POSEval();
      Object[] labels = state.getGoldLabels();
      DEPTree tree = state.getTree();
     
      e_eval.countAccuracy(tree, labels);
      tree.setPOSTags((String[])labels);
    }
  }
View Full Code Here

  {
    DEPReader reader = new DEPReader(0, 1, 2, 3, 4, 6, 7);
    reader.open(UTInput.createBufferedFileReader(args[0]));
    Prob1DMap map = new Prob1DMap();
    int[] count = {0, 0};
    DEPTree tree;
   
    while ((tree = reader.next()) != null)
      countDEP(tree, count, map);
   
    reader.close();
View Full Code Here

    DEPReader reader = new DEPReader(0, 1, 2, 3, 5, 6, 7);
    Set<String> set = Sets.newHashSet();
    String trainPath = args[0];
    String testPath  = args[1];
    PrintStream fout = UTOutput.createPrintBufferedFileStream(args[2]);
    DEPTree tree;
    int i, size;
    String str;
   
    for (String filename : UTFile.getInputFileList(trainPath, ".*.std"))
    {
      reader.open(UTInput.createBufferedFileReader(filename));
     
      while ((tree = reader.next()) != null)
      {
        size = tree.size();
       
        for (i=1; i<size; i++)
        {
          str = MPLib.simplifyBasic(tree.get(i).form);
          set.add(str);
        }
      }
     
      reader.close();
    }
   
    for (String filename : UTFile.getInputFileList(testPath, ".*.std"))
    {
      reader.open(UTInput.createBufferedFileReader(filename));
     
      while ((tree = reader.next()) != null)
      {
        size = tree.size();
       
        for (i=1; i<size; i++)
        {
          str = MPLib.simplifyBasic(tree.get(i).form);
         
          if (!set.contains(str))
          {
            fout.println(i);
            fout.println(tree.toStringDEP()+"\n");
            break;
          }
        }
      }
     
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

  }

  protected List<DEPTree> getTrees(JointReader reader, String[] filenames)
  {
    List<DEPTree> trees = Lists.newArrayList();
    DEPTree tree;
   
    for (String filename : filenames)
    {
      reader.open(UTInput.createBufferedFileReader(filename));
     
View Full Code Here

  protected 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.